Advertisement
benlloydjones

Project Euler 33

Jun 26th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. def PE33():
  2.     possibles = []
  3.     for x in range(10, 100, 1):
  4.         for y in range(10, 100, 1):
  5.             if x < y:
  6.                 fX = float(x)
  7.                 fY = float(y)
  8.                 val = fX / fY
  9.                 sX = str(x)
  10.                 sY = str(y)
  11.                 for z in range(1, 10, 1):
  12.                     sZ = str(z)
  13.                     if sX.count(sZ) == 1 and sY.count(sZ) == 1:
  14.                         jim = sX.replace(sZ, '')
  15.                         jack = sY.replace(sZ, '')
  16.                         if jim != '0' and jack != '0' and float(jim) / float(jack) == val and int(jim) < int(jack):
  17.                             if val not in possibles:
  18.                                 possibles.append(val)
  19.     dividend = 1
  20.     for x in possibles:
  21.         dividend *= x
  22.     answer = 1 / dividend
  23.     return int(round(answer, 0))
  24.  
  25. PE33()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement