(no title)
throwathrowaway | 10 years ago
Here's mine.
$ python -c 'import random;L=sorted(str(random.randint(1,9)) for i in range(4));a=raw_input(L);print(eval(a)==24,sorted(filter(str.isdigit,a))==L)'
['2', '6', '7', '8']8*(7+2-6)
(True, True)
Try to make it print (True, True) without abusing eval too much (intended to be +-*/() only with digits as tokens).A nicer interface, but too long:
import random;L=sorted(str(random.randint(1,9)) for i in range(4));a=raw_input(" ".join(L)+"\n> ");print(eval(a)==24,sorted(filter(str.isdigit,a))==L)
No comments yet.