Skip to content

Instantly share code, notes, and snippets.

@thermosilla
Created February 14, 2014 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thermosilla/8996333 to your computer and use it in GitHub Desktop.
Save thermosilla/8996333 to your computer and use it in GitHub Desktop.
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