mirror of
https://gitlab.com/MisterBiggs/advent-of-code-2019.git
synced 2025-06-16 15:17:15 +00:00
correct answer
This commit is contained in:
parent
8e2e692e34
commit
8a9afb39d4
@ -1,37 +1,13 @@
|
|||||||
start = 272091
|
start = 272091
|
||||||
end = 815432
|
end = 815432
|
||||||
|
|
||||||
index = start
|
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
|
for i in range(start, end):
|
||||||
|
code = [int(x) for x in list(str(i))]
|
||||||
|
|
||||||
def ascending(index):
|
if code == sorted(code):
|
||||||
for i in range(len(str(index)) - 1):
|
for c in code:
|
||||||
|
if code.count(c) >= 2:
|
||||||
a, b = str(index)[i], str(index)[i + 1]
|
count += 1
|
||||||
|
break
|
||||||
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)
|
print(count)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user