-
Notifications
You must be signed in to change notification settings - Fork 8
/
CSP.py
23 lines (20 loc) · 1.01 KB
/
CSP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def solutions():
# letters = ('s', 'e', 'n', 'd', 'm', 'o', 'r', 'y')
all_solutions = list()
for s in range(9, -1, -1):
for e in range(9, -1, -1):
for n in range(9, -1, -1):
for d in range(9, -1, -1):
for m in range(9, 0, -1):
for o in range(9, -1, -1):
for r in range(9, -1, -1):
for y in range(9, -1, -1):
if len(set([s, e, n, d, m, o, r, y])) == 8:
send = 1000 * s + 100 * e + 10 * n + d
more = 1000 * m + 100 * o + 10 * r + e
money = 10000 * m + 1000 * o + 100 * n + 10 * e + y
if send + more == money:
all_solutions.append(
(send, more, money))
return all_solutions
print(solutions())