1
0
mirror of https://gitlab.com/MisterBiggs/advent-of-code-2019.git synced 2025-06-16 15:17:15 +00:00

answer that I dont understand is wrong

This commit is contained in:
Anson 2019-12-03 23:32:47 -07:00
parent e2e3517bbd
commit 8e2e692e34

37
Day 4/code.py Normal file
View File

@ -0,0 +1,37 @@
start = 272091
end = 815432
index = start
count = 0
def ascending(index):
for i in range(len(str(index)) - 1):
a, b = str(index)[i], str(index)[i + 1]
if a > b:
index += 10 ** (len(str(index)) - i - 2) * abs(int(b) - int(a))
return ascending(index)
break
return index
while True:
index = ascending(index)
if index > end:
break
for i in range(len(str(index)) - 1):
a, b = str(index)[i], str(index)[i + 1]
if a == b:
count += 1
print(index)
break
index += 1
print(count)