maj
This commit is contained in:
33
d05/exemple1.txt
Normal file
33
d05/exemple1.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
seeds: 79 14 55 13
|
||||
|
||||
seed-to-soil map:
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
soil-to-fertilizer map:
|
||||
0 15 37
|
||||
37 52 2
|
||||
39 0 15
|
||||
|
||||
fertilizer-to-water map:
|
||||
49 53 8
|
||||
0 11 42
|
||||
42 0 7
|
||||
57 7 4
|
||||
|
||||
water-to-light map:
|
||||
88 18 7
|
||||
18 25 70
|
||||
|
||||
light-to-temperature map:
|
||||
45 77 23
|
||||
81 45 19
|
||||
68 64 13
|
||||
|
||||
temperature-to-humidity map:
|
||||
0 69 1
|
||||
1 0 69
|
||||
|
||||
humidity-to-location map:
|
||||
60 56 37
|
||||
56 93 4
|
22
d05/run.py
Normal file
22
d05/run.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import sys
|
||||
en=enumerate
|
||||
L = open(0).read().split('\n\n')
|
||||
L = [l.split(':') for l in L]
|
||||
L = [l[1].strip().split('\n') for l in L]
|
||||
L = [list(map(lambda x: tuple(map(int,x.split())),l)) for l in L]
|
||||
S = list(v for s in L[0] for v in s)
|
||||
|
||||
for i,l in en(L[1:]):
|
||||
print(i, l)
|
||||
# map all seads
|
||||
R = []
|
||||
for s in S:
|
||||
ns = None
|
||||
for dst, src, rg in l:
|
||||
if src <= s < src+rg:
|
||||
ns = dst+(s-src)
|
||||
break
|
||||
R.append(ns if ns else s)
|
||||
S = R
|
||||
print(S)
|
||||
print(min(S))
|
34
d05/run1_print.py
Normal file
34
d05/run1_print.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
|
||||
lmap=100
|
||||
|
||||
alma = [ele for ele in sys.stdin.read().splitlines() if ele != ""]
|
||||
planted = [int(ele) for ele in alma[0].replace("seeds: ", "").split(" ")]
|
||||
|
||||
source = list(range(0, lmap))
|
||||
destin = list(range(0, lmap))
|
||||
|
||||
for d in alma:
|
||||
if "map" not in d and "seeds:" not in d:
|
||||
r = [int(i) for i in d.split(" ")]
|
||||
print(r)
|
||||
print(source)
|
||||
print(destin)
|
||||
for n in range(0, r[2]):
|
||||
destin[r[1] + n] = source[r[0] + n]
|
||||
print(source)
|
||||
print(destin)
|
||||
print("")
|
||||
print("")
|
||||
|
||||
else:
|
||||
for i in planted:
|
||||
print(destin[i])
|
||||
source = list(destin)
|
||||
destin = list(range(0, lmap))
|
||||
print(d)
|
||||
|
||||
print(destin)
|
||||
for i in planted:
|
||||
print(destin[i])
|
||||
print(min(s) for s in destin)
|
Reference in New Issue
Block a user