day5: seems to have multiple mapping
This commit is contained in:
parent
ff5656b694
commit
1c5ffa221b
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python3
|
||||
# day 5 - Advent of Code 2023
|
||||
# part 1
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
with open("data/sample.txt", "r") as f:
|
||||
data = f.read()
|
||||
|
||||
parts = data.split("\n\n")
|
||||
|
||||
seeds = parts[0]
|
||||
seeds = seeds.split(": ")[1].split()
|
||||
seeds = list(map(int, seeds))
|
||||
|
||||
maps = [
|
||||
[
|
||||
[int(item) for item in values.split()]
|
||||
for values in themap.split("\n")[1:]
|
||||
if values != ""
|
||||
]
|
||||
for themap in parts[1:]
|
||||
]
|
||||
|
||||
|
||||
def recursive_min_descent(seed, maps):
|
||||
current = seed
|
||||
for submap in maps:
|
||||
for indication in submap:
|
||||
destination, source, size = indication
|
||||
return current
|
||||
|
||||
|
||||
"""
|
||||
soils = list(map(lambda seed: descent(seed, maps), seeds))
|
||||
|
||||
seeds = range(0, 99)
|
||||
|
||||
df = pd.DataFrame(
|
||||
dict(seed=seeds, soil=list(map(lambda seed: descent(seed, maps), seeds)))
|
||||
)
|
||||
|
||||
"""
|
||||
# Check that no map indication overlaps
|
||||
for submap in maps:
|
||||
for indication1 in submap:
|
||||
_, start1, range1 = indication1
|
||||
for indication2 in submap:
|
||||
if indication1 == indication2:
|
||||
continue
|
||||
_, start2, range2 = indication2
|
||||
if not (start2 > start1 + range1 or start1 > start2 + range2):
|
||||
print("overlap")
|
||||
|
||||
print(df)
|
Loading…
Reference in New Issue