1
0
Fork 0
This commit is contained in:
Lucidiot 2017-12-13 07:07:41 +01:00
commit 70319684ea
No known key found for this signature in database
GPG Key ID: 2C2A322692E18B6B
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))