Advertisement
danchaofan

Euler #125

Nov 27th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. testlist = [x for x in range(5, 10**8) if str(x) == str(x)[::-1]]
  2. groupSize, answers = 2, []
  3. upper = int((10 ** 8 / groupSize) ** 0.5) + 1
  4. while upper >= groupSize / 2:
  5.     print(upper, groupSize)
  6.     first = 1
  7.     while first != upper:
  8.         total = 0
  9.         for y in range(first, first + groupSize):
  10.             total += y ** 2
  11.         if total in testlist:
  12.             answers.append(total)
  13.         first += 1
  14.     first = 0
  15.     groupSize += 1
  16.     upper = int((10 ** 8 / groupSize) ** 0.5) + 1
  17. answers = set(answers)
  18. print(len(answers))
  19. print(sum(answers))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement