Skip to content

Instantly share code, notes, and snippets.

@orangain
Created February 9, 2011 10:07
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 orangain/818238 to your computer and use it in GitHub Desktop.
Save orangain/818238 to your computer and use it in GitHub Desktop.
#coding: utf-8
from itertools import permutations
operators = ('+', '-', '*', '/', '==')
for ordered_operators in permutations(operators):
equation = '5.%s4.%s3.%s2.%s1.%s0.' % ordered_operators
try:
if eval(equation):
print equation
except ZeroDivisionError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment