-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexps.py
More file actions
35 lines (28 loc) · 687 Bytes
/
exps.py
File metadata and controls
35 lines (28 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#code used to generate possible expressions (exps.txt)
from itertools import product
CHARS=list("+-*/0123456789")
f=open("./exps.txt",'w')
badops=["++","--","**","//","+-","-+","*+","*-","/+","/-",]
def badexps(x:str):
global badops
if x[0] in "+-*/0" or x[-1] in "+-*/" :
return True
for i in badops:
if i in x:
return True
try:
int(x)
return True
except:
pass
for i in product(CHARS,repeat=6):
exp=''.join(i)
try:
eval(exp)
if badexps(exp)==True:
continue
f.write(exp+"\n")
except:
pass
f.close()
print("done")