Skip to content

Commit

Permalink
add euler92 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
kailanefelix committed Oct 12, 2021
1 parent be78d0b commit a2a8734
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions euler0XX/euler092.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
count = 0
goes_to_1, goes_to_89 = {1}, {89}
for number in range(1, 10**7):
sequence = {number}
while True:
digit_sum = sum(int(i)**2 for i in str(number))
sequence.add(digit_sum)
if digit_sum in goes_to_1:
goes_to_1 = goes_to_1 | sequence
break
if digit_sum in goes_to_89:
goes_to_89 = goes_to_89 | sequence
count = count + 1
break
number = digit_sum

print(count)

0 comments on commit a2a8734

Please sign in to comment.