V4: Crypto Problem Generator and Solver Demo - CSC 366 Home Page - Code

...@...:~/Desktop/cog366/sets/v4$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.0-rc2)
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.

?- demo(1).
Numbers = { 1, 1, 1, 14, 7 } Goal = 7
Solution: ( ( 14 * ( ( 1 + 1 ) - 1 ) ) - 7 )
true .

?- demo(5).
Numbers = { 9, 2, 14, 7, 15 } Goal = 6
Solution: ( 15 - ( ( 9 + 2 ) - ( 14 / 7 ) ) )
Numbers = { 5, 11, 1, 10, 4 } Goal = 13
Solution: ( ( ( 1 + 10 ) - ( 5 - 11 ) ) - 4 )
Numbers = { 10, 4, 14, 0, 11 } Goal = 6
Solution: ( ( ( 10 + 0 ) + ( 4 * 14 ) ) / 11 )
Numbers = { 5, 0, 2, 6, 9 } Goal = 14
Solution: ( 6 - ( ( 5 - 9 ) * ( 0 + 2 ) ) )
Numbers = { 15, 8, 9, 4, 15 } Goal = 11
Solution: ( 15 - ( ( 9 + ( 15 - 8 ) ) / 4 ) )
true .

?- demo(10).
Numbers = { 7, 5, 6, 0, 14 } Goal = 0
Solution: ( 14 * ( ( 7 + 5 ) * ( 6 * 0 ) ) )
Numbers = { 15, 7, 2, 6, 5 } Goal = 5
Solution: ( ( ( 15 + 7 ) - ( 2 * 6 ) ) - 5 )
Numbers = { 1, 13, 8, 6, 11 } Goal = 1
Solution: ( ( ( 1 + 13 ) - ( 8 - 6 ) ) - 11 )
Numbers = { 8, 10, 15, 7, 12 } Goal = 13
Solution: ( ( ( 15 * 7 ) - ( 8 * 10 ) ) - 12 )
Numbers = { 5, 9, 5, 13, 7 } Goal = 15
Solution: ( ( ( 5 + 9 ) - ( 5 - 13 ) ) - 7 )
Numbers = { 1, 8, 3, 14, 4 } Goal = 15
Solution: ( 4 + ( 14 - ( ( 1 + 8 ) / 3 ) ) )
Numbers = { 10, 6, 3, 7, 7 } Goal = 4
Solution: ( 7 + ( ( 7 - ( 10 + 6 ) ) / 3 ) )
Numbers = { 12, 9, 3, 11, 6 } Goal = 10
Solution: ( 6 + ( 11 - ( ( 12 + 9 ) / 3 ) ) )
Numbers = { 15, 1, 7, 10, 8 } Goal = 11
Solution: ( ( ( 15 + 1 ) - ( 7 - 10 ) ) - 8 )
Numbers = { 5, 8, 5, 7, 9 } Goal = 4
Solution: ( 9 - ( ( 5 * 8 ) - ( 5 * 7 ) ) )
true .

?-