Cryptarithmetic

Started by cameyo, March 19, 2022, 12:22:18 PM

Previous topic - Next topic

cameyo

Solve this (each letter represent a different digit):
  LISP *
    FUN =
---------
NEWLISP

There are three solution.

p.s. obviously you have to use newlisp :-)

cameyo

#1
((("e" 9) ("f" 7) ("i" 6) ("l" 2) ("n" 1) ("p" 0) ("s" 4) ("u" 5) ("w" 8))
 (("e" 8) ("f" 2) ("i" 3) ("l" 7) ("n" 1) ("p" 0) ("s" 6) ("u" 5) ("w" 4))
 (("e" 9) ("f" 2) ("i" 8) ("l" 7) ("n" 1) ("p" 0) ("s" 4) ("u" 5) ("w" 6)))

rrq

#2
.. and you should dazzle me with the code as well :)



I had a hard time avoiding brute-force, which I thought too boring, but then it started to take too much time for me so I gave up.



Ralph.

cameyo

#3
Hi Ralph, i have two functions to solve puzzle like this: one uses brute-force and the other uses "amb" :-))

https://github.com/cameyo42/newLISP-Note/blob/master/15-note-libere-7.lsp#L9296">//https://github.com/cameyo42/newLISP-Note/blob/master/15-note-libere-7.lsp#L9296

rickyboy

#4
Thanks for posting the puzzle and your solution, cameyo!



I found the same 3 you found.  I wish I could post them here but alas I'm getting the Internal Server Error page; so I'll just post a link to the code.  The solution printout is in a comment at the bottom.



Like Ralph, I could not think of anything besides brute-force, but I added a little wrinkle that reduced the number of iterations by 6 times, so that it would run faster and, for that reason, wouldn't be "too boring." :)



https://git.sr.ht/~rick/newlisp-cryptarithmetic-puzzle/tree/master/item/lisp%2Afun%3Dnewlisp.lsp">https://git.sr.ht/~rick/newlisp-cryptar ... ewlisp.lsp">https://git.sr.ht/~rick/newlisp-cryptarithmetic-puzzle/tree/master/item/lisp%2Afun%3Dnewlisp.lsp
(λx. x x) (λx. x x)