1
0
Fork 0

Puzzle du 13 décembre 2017

This commit is contained in:
Lucidiot 2017-12-13 07:14:23 +01:00
parent 70319684ea
commit f0abc59439
No known key found for this signature in database
GPG Key ID: 2C2A322692E18B6B
1 changed files with 2 additions and 0 deletions

View File

@ -5,5 +5,7 @@ def scanner_pos(length, time):
return 2 * (length - 1) - offset if offset > length - 1 else offset
import sys
import itertools
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))
print(next(time for time in itertools.count() if not any(scanner_pos(ranges[pos], time + pos) == 0 for pos in ranges)))