summaryrefslogtreecommitdiffstats
path: root/src/s3select/example/expr_genrator.py
blob: 5905e9832943b74c35190f7a8999b5b76396f5b7 (plain)
1
2
3
4
5
6
7
8
9
import random
import sys

def expr(depth):
    if depth==1 or random.random()<1.0/(2**depth-1): 
        return str(int(random.random() * 100) + 1)+".0"
    return '(' + expr(depth-1) + random.choice(['+','-','*','/']) + expr(depth-1) + ')'

print (expr( int(sys.argv[1]) ))