2017: d17: ex2: add solution
This commit is contained in:
parent
d636ec9673
commit
0b148f649d
1 changed files with 25 additions and 0 deletions
25
2017/d17/ex2/ex2.py
Executable file
25
2017/d17/ex2/ex2.py
Executable file
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue