You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
623 B
36 lines
623 B
4 years ago
|
import itertools
|
||
|
|
||
|
|
||
|
permutation_list = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "=="]
|
||
|
|
||
|
permutations = list(itertools.permutations(permutation_list))
|
||
|
|
||
|
print(len(permutations))
|
||
|
|
||
|
for p in permutations:
|
||
|
|
||
|
# int(p[0]) * int(p[1] + p[2])
|
||
|
|
||
|
try:
|
||
|
if eval(''.join(p)):
|
||
|
print(''.join(p).split("=="))
|
||
|
except:
|
||
|
pass
|
||
|
|
||
|
|
||
|
# ['12*483', '5796']
|
||
|
# ['138*42', '5796']
|
||
|
# ['159*48', '7632']
|
||
|
# ['1738*4', '6952']
|
||
|
# ['186*39', '7254']
|
||
|
# ['18*297', '5346']
|
||
|
# ['1963*4', '7852']
|
||
|
# ['198*27', '5346']
|
||
|
# ['28*157', '4396']
|
||
|
|
||
|
y = 0
|
||
|
for i in [5796, 7632, 6952, 7254, 7852, 4396, 5346]:
|
||
|
y += i
|
||
|
|
||
|
print(y)
|