-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq33.py
More file actions
38 lines (32 loc) · 1.09 KB
/
q33.py
File metadata and controls
38 lines (32 loc) · 1.09 KB
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
36
37
from sieve import sieve
primes = sieve(100)
def reduc(top,bot):
for prime in primes:
while (True):
if(top%prime==0 and bot%prime==0):
top = top/prime
bot = bot/prime
else:
break
return [top,bot]
results = []
for i in range (10,100):
digits = map(int,str(i))
for j in range (i+1,100):
digits2 = map(int,str(j))
if(not(digits[1]==0 or digits2[1]==0)):
if(digits[0]==digits2[0] and (reduc(i,j) == reduc(digits[1],digits2[1]))):
results.append([i,j])
elif (digits[0] == digits2[1] and (reduc(i, j) == reduc(digits[1], digits2[0]))):
results.append([i, j])
elif (digits[1] == digits2[0] and (reduc(i, j) == reduc(digits[0], digits2[1]))):
results.append([i, j])
elif (digits[1] == digits2[1] and (reduc(i, j) == reduc(digits[0], digits2[0]))):
results.append([i, j])
numer = 1
denom = 1
for i in results:
print i
numer = numer*i[0]
denom = denom*i[1]
print reduc(numer,denom)