Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short, Simple, Speedy solution in Creative category for Reverse Engineer by StefanPochmann
from fractions import Fraction
def check(expr, step):
x, y = map(Fraction, step[:2])
try:
value = eval(expr)
return step[2] == [value.numerator, value.denominator]
except:
return step[2][0] == 'Z'
def checkio(steps):
E = ['xy']
while True:
for expr in E[-1]:
if all(check(expr, step) for step in steps):
return expr, 3141592653589793, 2718281828459045
E += [{'(' + a + op + b + ')'
for A, B in zip(E, E[::-1]) for a in A for b in B
for op in '+-*/'}]
April 29, 2015
Comments: