Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import itertools
- def make_range(x):
- x = eval(x)
- if type(x) != type(()): # tuple
- x = x,x
- return xrange(x[0], x[1] + 1)
- formula = raw_input()
- inp = raw_input()
- if not inp.split():
- print eval(formula)
- exit()
- dic = {key:make_range(val) for key, val in map(lambda s: s.split("="), inp.split(" "))}
- import math
- math_map ={ i:j for i,j in zip(dir(math), map(lambda name: eval("math."+name), dir(math)))}
- print max(eval(formula, dict(math_map.items() + { k:j for k,j in zip(dic.keys(), i)}.items())) for i in itertools.product(*dic.values()) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement