Skip to content

Instantly share code, notes, and snippets.

@duckyuck
Created December 6, 2012 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duckyuck/4229449 to your computer and use it in GitHub Desktop.
Save duckyuck/4229449 to your computer and use it in GitHub Desktop.
SEND + MORE = MONEY in core.logic
(run 1 [q]
(fresh [S E N D M O R Y SEND MORE MONEY]
(infd S E N D M O R Y (interval 0 9))
(distinctfd [S E N D M O R Y])
(eqfd
(!= S 0)
(!= M 0)
(= SEND (+ (* S 1000)
(* E 100)
(* N 10)
D))
(= MORE (+ (* M 1000)
(* O 100)
(* R 10)
E))
(= MONEY (+ (* M 10000)
(* O 1000)
(* N 100)
(* E 10)
Y))
(= (+ SEND MORE) MONEY))
;; Spins idefinitely
;; (== q {:S S :E E :N N :D D :M M :O O :R R :Y Y}
(== q [S E N D M O R Y])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment