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)