This is literally not my code

This commit is contained in:
akp 2023-12-06 00:52:59 +00:00
parent e47523750c
commit a5250cc4e9
No known key found for this signature in database
GPG key ID: CF8D58F3DEB20755

View file

@ -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])]])