From 08ab7201abdb9417dc732e5e9d6f60c96f2bef78 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Sun, 3 Dec 2023 07:56:29 +0100 Subject: [PATCH] Added matrix for part1 and neighbor function --- 2023/day3/part1/part1.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/2023/day3/part1/part1.py b/2023/day3/part1/part1.py index e658c4b..1c58f86 100644 --- a/2023/day3/part1/part1.py +++ b/2023/day3/part1/part1.py @@ -25,5 +25,20 @@ neighbors = lambda x, y : [(x2, y2) for x2 in range(x-1, x+2) (x != x2 or y != y2) and (0 <= x2 <= X) and (0 <= y2 <= Y))] -pprint(neighbors(4,2)) + +for idx,i in enumerate(arr): + for jdx,j in enumerate(i): + tmp = arr[idx][jdx] + if tmp.isdigit() == False and tmp != '.': + print(tmp) + print(idx,jdx) + +n = neighbors(4,2) + +pprint(n) + +for i in n: + print(i) + print(arr[i[0]][i[1]]) +