mba:crypto_xps johnz$ swipl Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.3) SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software. Please run ?- license. for legal details. For online help and background, visit http://www.swi-prolog.org For built-in help, use ?- help(Topic). or ?- apropos(Word). ?- consult('crypto.pro'). true. ?- display_bindings. lo ---> 0 hi ---> 9 true. ?- solve_one. Problem : numbers = {2, 3, 1, 1, 6} and goal = 6 Solution: ( 6 + ( ( 2 + 3 ) * ( 1 - 1 ) ) ) true . ?- demo(5). Problem : numbers = {3, 2, 3, 5, 8} and goal = 0 Solution: ( ( 3 + 2 ) * ( ( 3 + 5 ) - 8 ) ) Problem : numbers = {6, 1, 5, 5, 8} and goal = 0 Solution: ( ( 5 - 5 ) * ( 8 + (6 + 1 ) ) ) Problem : numbers = {7, 4, 0, 9, 0} and goal = 0 Solution: ( ( 0 + 9 ) * ( 0 * ( 7 + 4 ) ) ) Problem : numbers = {0, 2, 2, 2, 8} and goal = 0 Solution: ( ( 8 / ( 0 + 2 ) ) - ( 2 + 2 ) ) Problem : numbers = {2, 5, 2, 5, 9} and goal = 0 Solution: ( 9 * ( ( 2 + 5 ) - ( 2 + 5 ) ) ) true . ?- display_bindings. lo ---> 0 hi ---> 9 crypto_problem ---> problem(numbers(2,5,2,5,9),goal(0)) solution ---> solution(ex(9, *, ex(ex(2, +, 5), -, ex(2, +, 5)))) true. ?- solve(problem(numbers(0,0,0,0,7),goal(8))). Problem : numbers = {0, 0, 0, 0, 7} and goal = 8 No solution to this problem. true . ?- display_bindings. lo ---> 0 hi ---> 9 crypto_problem ---> problem(numbers(0,0,0,0,7),goal(8)) solution ---> solution(none) true. ?- halt. mba:crypto_xps johnz$