From b7b359d3f836cc531292b94a383f8c091fa1d8dd Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Sun, 3 Dec 2023 07:02:39 +0100 Subject: [PATCH] starting day3 --- 2023/day3/part1/part1.py | 29 +++++++++++++++++++++++++++++ 2023/day3/part1/test | 10 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 2023/day3/part1/part1.py create mode 100644 2023/day3/part1/test diff --git a/2023/day3/part1/part1.py b/2023/day3/part1/part1.py new file mode 100644 index 0000000..e658c4b --- /dev/null +++ b/2023/day3/part1/part1.py @@ -0,0 +1,29 @@ +#!/bin/python3 + +import re +import sys +from pprint import pprint +input_f = sys.argv[1] +count = 0 +arr = [] + + + + + +with open(input_f) as file: + for line in file: + arr.append(list(line.lstrip().rstrip())) + +pprint(arr) +X=len(arr[0]) +Y=len(arr) +neighbors = lambda x, y : [(x2, y2) for x2 in range(x-1, x+2) + for y2 in range(y-1, y+2) + if (-1 < x <= X and + -1 < y <= Y and + (x != x2 or y != y2) and + (0 <= x2 <= X) and + (0 <= y2 <= Y))] +pprint(neighbors(4,2)) + diff --git a/2023/day3/part1/test b/2023/day3/part1/test new file mode 100644 index 0000000..b20187f --- /dev/null +++ b/2023/day3/part1/test @@ -0,0 +1,10 @@ +467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598..