]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | import random |
2 | import sys | |
3 | ||
4 | def expr(depth): | |
5 | if depth==1 or random.random()<1.0/(2**depth-1): | |
6 | return str(int(random.random() * 100) + 1)+".0" | |
7 | return '(' + expr(depth-1) + random.choice(['+','-','*','/']) + expr(depth-1) + ')' | |
8 | ||
20effc67 | 9 | print (expr( int(sys.argv[1]) )) |