This is literally not my code
This commit is contained in:
parent
e47523750c
commit
a5250cc4e9
1 changed files with 0 additions and 23 deletions
|
@ -1,23 +0,0 @@
|
||||||
from functools import reduce
|
|
||||||
import sys
|
|
||||||
|
|
||||||
seeds, *mappings = open(sys.argv[1]).read().strip().split('\n\n')
|
|
||||||
seeds = list(map(int, seeds.split()[1:]))
|
|
||||||
|
|
||||||
def lookup(inputs, mapping):
|
|
||||||
for start, length in inputs:
|
|
||||||
while length > 0:
|
|
||||||
for m in mapping.split('\n')[1:]:
|
|
||||||
dst, src, len = map(int, m.split())
|
|
||||||
delta = start - src
|
|
||||||
if delta in range(len):
|
|
||||||
len = min(len - delta, length)
|
|
||||||
yield (dst + delta, len)
|
|
||||||
start += len
|
|
||||||
length -= len
|
|
||||||
break
|
|
||||||
else: yield (start, length); break
|
|
||||||
|
|
||||||
print(*[min(reduce(lookup, mappings, s))[0] for s in [
|
|
||||||
zip(seeds, [1] * len(seeds)),
|
|
||||||
zip(seeds[0::2], seeds[1::2])]])
|
|
Loading…
Add table
Add a link
Reference in a new issue