Skip to content
Snippets Groups Projects
Commit 9547fad4 authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Solved 33

parent b8de0807
No related branches found
No related tags found
No related merge requests found
def gcd(a, b):
while b:
a, b = b, a % b
return a
#!/usr/bin/env python
from __future__ import division
from itertools import combinations, permutations
from frac import gcd
nrs = [(i, str(i)) for i in xrange(10, 100)]
pairs = ((0, 0), (0, 1), (1, 0), (1, 1))
pn = pd = 1
for (n, ns), (d, ds) in combinations(nrs, 2):
if n < d:
for i, j in pairs:
if ds[1 - j] != '0' and ns[i] == ds[j] \
and int(ns[1 - i]) / int(ds[1 - j]) == n / d \
and ns[1] != '0':
pn *= n
pd *= d
print '%d / %d == %s / %s' % (n, d, ns[1 - i], ds[1 - j])
g = gcd(pn, pd)
print 'product: %d / %d' % (pn/ g, pd / g)
print 'answer: %d' % (pd / g)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment