d5
This commit is contained in:
parent
949bccf51f
commit
64c888dc50
39
day05.py
Normal file
39
day05.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
from tools.aoc import AOCDay
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
|
class Day(AOCDay):
|
||||||
|
inputs = [
|
||||||
|
[
|
||||||
|
(364539, "input5")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
(27477714, "input5")
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_steps(self, p2: bool = False) -> int:
|
||||||
|
inst = self.getInputListAsType(int)
|
||||||
|
index = 0
|
||||||
|
count = 0
|
||||||
|
while 0 <= index < len(inst):
|
||||||
|
count += 1
|
||||||
|
if p2 and inst[index] >= 3:
|
||||||
|
inst[index] -= 1
|
||||||
|
index += inst[index] + 1
|
||||||
|
else:
|
||||||
|
inst[index] += 1
|
||||||
|
index += inst[index] - 1
|
||||||
|
|
||||||
|
return count
|
||||||
|
|
||||||
|
def part1(self) -> Any:
|
||||||
|
return self.get_steps()
|
||||||
|
|
||||||
|
def part2(self) -> Any:
|
||||||
|
return self.get_steps(True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
day = Day(2017, 5)
|
||||||
|
day.run(verbose=True)
|
||||||
1074
inputs/input5
Normal file
1074
inputs/input5
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user