Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
4444
import operator
nums = {
1: "(4/4)",
2: "(4/r(4))",
4: "(r(4)+r(4))",
6: "(r(4)+4)",
8: "(4+4)",
9: "(4/.4')",
10: "(4/.4)",
12: "(4!/r(4))",
16: "(r(4)^4)",
44: "44",
48: "(4!*r(4))",
60: "(4!/.4)",
96: "(4!*4)",
}
ops = {
"+": operator.add,
"-": operator.sub,
"*": operator.mul,
"/": operator.truediv
}
def descompone(x, func):
res = (nums[i] + op + nums[j]
for i in nums.keys() for j in nums.keys()
for op in func.keys()
if x == func[op](i, j))
return next(res, None)
if __name__ == '__main__':
for i in range(1, 101):
print("{0} = {1}".format(i, descompone(i, ops)))
# print(descompone(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment