Last active
January 13, 2016 13:44
-
-
Save xman/87de4530cdeec4e6eda0 to your computer and use it in GitHub Desktop.
SEND MORE MONEY (code adopted from erl and python code provided by NNH)
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
#include <stdio.h> | |
int main() | |
{ | |
for (int s = 0; s < 10; s++) { | |
for (int e = 0; e < 10; e++) { | |
for (int n = 0; n < 10; n++) { | |
for (int d = 0; d < 10; d++) { | |
for (int m = 0; m < 10; m++) { | |
for (int o = 0; o < 10; o++) { | |
for (int r = 0; r < 10; r++) { | |
for (int y = 0; y < 10; y++) { | |
if (s > 0 && m > 0 && | |
s != e && s != n && s != d && s != m && s != o && s != r && s != y && | |
e != n && e != d && e != m && e != o && e != r && e != y && | |
n != d && n != m && n != o && n != r && n != y && | |
d != m && d != o && d != r && d != y && | |
m != o && m != r && m != y && | |
o != r && o != y && | |
r != y && | |
(s*1000+e*100+n*10+d)+(m*1000+o*100+r*10+e)==(m*10000+o*1000+n*100+e*10+y)) { | |
printf("s=%d e=%d n=%d d=%d m=%d o=%d r=%d y=%d\n", s, e, n, d, m, o, r, y); | |
} | |
}}}}}}}} | |
return 0; | |
} |
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
-module(sendmore). | |
-export([sendmore/0]). | |
sendmore() -> [ | |
{S,E,N,D,M,O,R,E,M,O,N,E,Y} || | |
S <- lists:seq(0,9), | |
E <- lists:seq(0,9), | |
N <- lists:seq(0,9), | |
D <- lists:seq(0,9), | |
M <- lists:seq(0,9), | |
O <- lists:seq(0,9), | |
R <- lists:seq(0,9), | |
Y <- lists:seq(0,9), | |
S > 0, M > 0, | |
S /= E, S /= N, S /= D, S /= M, | |
S /= O, S/= R, S /=Y, | |
E /= N, E /= D, E /= M, E /= O, | |
E /= R, E /= Y, | |
N /= D, N /= M, N /= O, N /= R, | |
N /= Y, | |
D /= M, D /= O, D /= R, D /= Y, | |
M /= O, M /= R, M /= Y, | |
O /= R, O /= Y, | |
R /= Y, | |
((S*1000+E*100+N*10+D) | |
+ | |
(M*1000+O*100+R*10+E)) | |
== | |
(M*10000+O*1000+N*100+E*10+Y) | |
]. |
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
for (s = 0; s < 10; s++) { | |
for (e = 0; e < 10; e++) { | |
for (n = 0; n < 10; n++) { | |
for (d = 0; d < 10; d++) { | |
for (m = 0; m < 10; m++) { | |
for (o = 0; o < 10; o++) { | |
for (r = 0; r < 10; r++) { | |
for (y = 0; y < 10; y++) { | |
if (s > 0 && m > 0 && | |
s != e && s != n && s != d && s != m && s != o && s != r && s != y && | |
e != n && e != d && e != m && e != o && e != r && e != y && | |
n != d && n != m && n != o && n != r && n != y && | |
d != m && d != o && d != r && d != y && | |
m != o && m != r && m != y && | |
o != r && o != y && | |
r != y && | |
(s*1000+e*100+n*10+d)+(m*1000+o*100+r*10+e)==(m*10000+o*1000+n*100+e*10+y)) { | |
console.log("s=%d e=%d n=%d d=%d m=%d o=%d r=%d y=%d\n", s, e, n, d, m, o, r, y); | |
} | |
}}}}}}}} |
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
[(S, E, N, D, M, O, R, E, M, O, N, E, Y) | |
for S in range(0,10) | |
for E in range(0,10) | |
for N in range(0,10) | |
for D in range(0,10) | |
for M in range(0,10) | |
for O in range(0,10) | |
for R in range(0,10) | |
for Y in range(0,10) | |
if S > 0 and M > 0 and | |
S != E and S != N and S != D and S != M and S != O and S != R and S != Y and | |
E != N and E != D and E != M and E != O and E != R and E != Y and | |
N != D and N != M and N != O and N != R and N != Y and | |
D != M and D != O and D != R and D != Y and | |
M != O and M != R and M != Y and | |
O != R and O != Y and | |
R != Y and | |
((S*1000+E*100+N*10+D)+(M*1000+O*100+R*10+E)==(M*10000+O*1000+N*100+E*10+Y)) | |
] |
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
for s in 0...10 | |
for e in 0...10 | |
for n in 0...10 | |
for d in 0...10 | |
for m in 0...10 | |
for o in 0...10 | |
for r in 0...10 | |
for y in 0...10 | |
if s > 0 && m > 0 && | |
s != e && s != n && s != d && s != m && s != o && s != r && s != y && | |
e != n && e != d && e != m && e != o && e != r && e != y && | |
n != d && n != m && n != o && n != r && n != y && | |
d != m && d != o && d != r && d != y && | |
m != o && m != r && m != y && | |
o != r && o != y && | |
r != y && | |
(s*1000+e*100+n*10+d)+(m*1000+o*100+r*10+e)==(m*10000+o*1000+n*100+e*10+y) | |
puts "s=%d e=%d n=%d d=%d m=%d o=%d r=%d y=%d" % [s, e, n, d, m, o, r, y] | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment