Project Euler Problem 33
I wrote a bunch of these but never posted them up, so I'm just uploading them in bulk now. Not much to say about them at this point.
- #!/usr/bin/python
- for n in range(10, 100):
- if n % 10 != 0:
- for d in range(10, 100):
- if d % 10 != 0 and d != n:
- s_n = str(n)
- s_d = str(d)
- n_n = 0
- n_d = 0
- if s_n[0] == s_n[1] or s_d[0] == s_d[1]:
- continue
- if s_n[0] == s_d[0]:
- n_n = s_n[1]
- n_d = s_d[1]
- elif s_n[0] == s_d[1]:
- n_n = s_n[1]
- n_d = s_d[0]
- elif s_n[1] == s_d[0]:
- n_n = s_n[0]
- n_d = s_d[1]
- elif s_n[1] == s_d[1]:
- n_n = s_n[0]
- n_d = s_d[0]
- if n_n and n_d:
- test_1 = float(n)/float(d)
- test_2 = float(n_n)/float(n_d)
- if test_1 == test_2 and test_1 < 1:
- print "%s/%s" % (str(n), str(d))