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()