From 5dd864d989f52764870e164e7ac8d0eec70d6a06 Mon Sep 17 00:00:00 2001 From: mitchellhansen Date: Sun, 25 Oct 2020 20:14:28 -0700 Subject: [PATCH] prob 32 --- problem_32.py | 35 +++++++++++++++++++++++++++++++++++ problem_33.py | 0 2 files changed, 35 insertions(+) create mode 100644 problem_32.py create mode 100644 problem_33.py diff --git a/problem_32.py b/problem_32.py new file mode 100644 index 0000000..a3fe75d --- /dev/null +++ b/problem_32.py @@ -0,0 +1,35 @@ +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) diff --git a/problem_33.py b/problem_33.py new file mode 100644 index 0000000..e69de29