From 0b148f649d3b623ac13797f0eb7a018c89bef1b4 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 10 May 2025 13:46:26 +0100 Subject: [PATCH] 2017: d17: ex2: add solution --- 2017/d17/ex2/ex2.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 2017/d17/ex2/ex2.py diff --git a/2017/d17/ex2/ex2.py b/2017/d17/ex2/ex2.py new file mode 100755 index 0000000..5fab2dc --- /dev/null +++ b/2017/d17/ex2/ex2.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import collections +import sys + + +def solve(input: str) -> int: + def parse(input: str) -> int: + return int(input.strip()) + + lock = collections.deque([0]) + step = parse(input) + for i in range(1, 50000000 + 1): + lock.rotate(-step) + lock.append(i) + return lock[lock.index(0) + 1] + + +def main() -> None: + input = sys.stdin.read() + print(solve(input)) + + +if __name__ == "__main__": + main()