Created
February 14, 2014 05:38
-
-
Save thermosilla/8996333 to your computer and use it in GitHub Desktop.
4444
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
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