Created
September 23, 2019 18:43
-
-
Save pragdave/42aeea278c510aafe8feaee0ca4096f4 to your computer and use it in GitHub Desktop.
naive implementation of the cryptoarithmetic puzzle SEND + MORE = MONEY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Solve SEND + MORE = MONEY | |
select S.i, E.i, N.i, D.i, M.i, O.i, R.i, Y.i | |
from digits S, digits E, digits N, digits D, | |
digits M, digits O, digits R, digits Y | |
where S.i != 0 | |
and M.i = 1 | |
and (S.i + M.i)*1000 + (E.i + O.i)*100 + (N.i + R.i)*10 + D.i + E.i | |
= M.i*10000 + O.i*1000 + N.i*100 + E.i*10 + Y.i | |
and S.i not in ( E.i, N.i, D.i, M.i, O.i, R.i, Y.i) | |
and E.i not in ( N.i, D.i, M.i, O.i, R.i, Y.i) | |
and N.i not in ( D.i, M.i, O.i, R.i, Y.i) | |
and D.i not in ( M.i, O.i, R.i, Y.i) | |
and M.i not in ( O.i, R.i, Y.i) | |
and O.i not in ( R.i, Y.i) | |
and R.i != Y.i; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LOL