1
0
Fork 0

Puzzle du 13 décembre, partie 1\nJe continuerai dans le train

This commit is contained in:
Lucidiot 2017-12-13 06:32:39 +01:00
parent e59e8a584f
commit 8e4f3a10ea
No known key found for this signature in database
GPG Key ID: 63BD9482C29D0F64
1 changed files with 9 additions and 0 deletions

9
2017/13/firewall.py Normal file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env python3
def scanner_pos(length, time):
offset = time % ((length - 1) * 2)
return 2 * (length - 1) - offset if offset > length - 1 else offset
import sys
ranges = {k: v for (k, v) in [tuple(map(int, l.strip().split(": "))) for l in sys.stdin.readlines()]}
print(sum(pos * ranges[pos] for pos in ranges if scanner_pos(ranges[pos], pos) == 0))