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.

  1. #!/usr/bin/python
  2.  
  3. for n in range(10, 100):
  4.     if n % 10 != 0:
  5.         for d in range(10, 100):
  6.             if d % 10 != 0 and d != n:
  7.                 s_n = str(n)
  8.                 s_d = str(d)
  9.                 n_n = 0
  10.                 n_d = 0
  11.                 if s_n[0] == s_n[1] or s_d[0] == s_d[1]:
  12.                     continue
  13.                 if s_n[0] == s_d[0]:
  14.                     n_n = s_n[1]
  15.                     n_d = s_d[1]
  16.                 elif s_n[0] == s_d[1]:
  17.                     n_n = s_n[1]
  18.                     n_d = s_d[0]
  19.                 elif s_n[1] == s_d[0]:
  20.                     n_n = s_n[0]
  21.                     n_d = s_d[1]
  22.                 elif s_n[1] == s_d[1]:
  23.                     n_n = s_n[0]
  24.                     n_d = s_d[0]
  25.  
  26.                 if n_n and n_d:
  27.                     test_1 = float(n)/float(d)
  28.                     test_2 = float(n_n)/float(n_d)
  29.                     if test_1 == test_2 and test_1 < 1:
  30.                         print "%s/%s" % (str(n), str(d))