From e71d2143166f6e8b2e706e84fdc7a2768d97ea80 Mon Sep 17 00:00:00 2001 From: Thom Dickson Date: Mon, 6 Dec 2021 14:22:55 -0500 Subject: [PATCH] Work on day05 part1 --- day05/day05.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/day05/day05.py b/day05/day05.py index 4cfb260..ebf842f 100644 --- a/day05/day05.py +++ b/day05/day05.py @@ -1,4 +1,6 @@ def ingest(input): + """Parse the input data and load it into a working datastructure to solve + the problem""" paths = [] for line in input: print(line) @@ -7,11 +9,20 @@ def ingest(input): return paths +def build_chart(paths): + """Create an empty table using the largest x and y values""" + size_x = max([x[0][0] for x in paths] + [x[1][0] for x in paths]) + size_y = max([y[0][1] for y in paths] + [y[1][1] for y in paths]) + chart = [[0 for x in range(size_x)] for y in range(size_y)] + return chart + + def part1(): + """Solution for part one of day05""" with open("day05.in", "r") as f: paths = ingest([line.rstrip() for line in f]) - print([[x[0][0], x[1][0]] for x in paths]) - print(paths) + chart = build_chart(paths) + [print(line) for line in chart] def main():