-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler33.py
More file actions
29 lines (26 loc) · 947 Bytes
/
euler33.py
File metadata and controls
29 lines (26 loc) · 947 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
def fractiontest(num,denom):
value = float(num)/float(denom)
frac = [[int(str(num)[0]),int(str(num)[1])],[int(str(denom)[0]),int(str(denom)[1])]]
if frac[0] == frac[1]:
return False
elif frac[0][0] == frac [1][0] and frac[1][1] != 0:
valuetest = float(frac[0][1])/float(frac[1][1])
elif frac[0][0] == frac[1][1] and frac[1][0] != 0:
valuetest = float(frac[0][1])/float(frac[1][0])
elif frac[0][1] == frac[1][0] and frac[1][1] != 0:
valuetest = float(frac[0][0])/float(frac[1][1])
elif frac[0][1] == frac[1][1] and frac[1][0] != 0:
valuetest = float(frac[0][0])/float(frac[1][0])
else:
return False
if valuetest == value:
return True
else:
return False
for num in xrange(10,100):
for denom in xrange(num,100):
if fractiontest(num,denom):
print num,"/",denom
#note: does not give full solution, must hand search the possibilites
# and eliminate trivial answer.
# correct answers: (16/64), (19/95), (49/98), (26/65)