From aaca415d2b7cf1c875f209a00c203b03e0e846b3 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Mon, 11 Dec 2023 14:25:28 +0100 Subject: [PATCH] Working on 2023-12-10 p1 --- 2023/day10/part1.py | 32 ++++++++++++++++++++------------ 2023/day10/t3 | 5 +++++ 2023/day10/t4 | 5 +++++ 2023/day10/t5 | 5 +++++ 2023/day10/t6 | 5 +++++ 2023/day10/t7 | 7 +++++++ 6 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 2023/day10/t3 create mode 100644 2023/day10/t4 create mode 100644 2023/day10/t5 create mode 100644 2023/day10/t6 create mode 100644 2023/day10/t7 diff --git a/2023/day10/part1.py b/2023/day10/part1.py index 1b5b57a..1ba0be1 100644 --- a/2023/day10/part1.py +++ b/2023/day10/part1.py @@ -94,40 +94,48 @@ while not found: #print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new)) dirc = 'R' if wall(cur) in ('─','┌','└','S'): + if wall(new) == 'S': + print('Found') + found = True #print('Went Right') prev = (y,x) y += 1 + print(wall(new)) sub_found = True if y > 0 and not sub_found: #print('Can go left') # Left new = (list(cur)[0]-1,list(cur)[1]) - #print(wall(new)) - found = True if wall(new) == 'S' else False if grid[x][y-1] in ('─','┌','└') and new != prev: #print('Trying Left') #print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new)) dirc = 'L' if wall(cur) in ('─','┐','┘','S'): + if wall(new) == 'S': + print('Found') + found = True #print('Went Left') prev = (y,x) y -= 1 + print(wall(new)) sub_found = True if x > 0 and not sub_found: - #print('Can go up') + print('Can go up') # Up new = (list(cur)[0],list(cur)[1]-1) #print(wall(new)) - found = True if wall(new) == 'S' else False - if grid[x-1][y] in ('│','┌','┐') and new != prev: - #print('Trying Up') - #print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new)) + if grid[x-1][y] in ('│','┌','┐','S') and new != prev: + print('Trying Up') + print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new)) dirc = 'U' if wall(cur) in ('│','└','┘','S'): - #print('Went Up') + print('Went Up') + if wall(new) == 'S': + print('Found') + found = True prev = (y,x) x -=1 sub_found = True @@ -137,15 +145,15 @@ while not found: # Down new = (list(cur)[0],list(cur)[1]+1) #print(wall(new)) - if wall(new) == 'S': - #print('Found the S') - found = True - if grid[x+1][y] in ('│','└','┘') and new != prev: + if grid[x+1][y] in ('│','└','┘','S') and new != prev: #print('Trying Down') #print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new)) dirc = 'D' if wall(cur) in ('│','┌','┐','S'): #print('Went Down') + if wall(new) == 'S': + print('Found') + found = True prev = (y,x) x += 1 sub_found = True diff --git a/2023/day10/t3 b/2023/day10/t3 new file mode 100644 index 0000000..5b5a9af --- /dev/null +++ b/2023/day10/t3 @@ -0,0 +1,5 @@ +..F.F7. +.7.FJ|. +.|SJ.L7 +..|F--J +..LJ... diff --git a/2023/day10/t4 b/2023/day10/t4 new file mode 100644 index 0000000..116dbd4 --- /dev/null +++ b/2023/day10/t4 @@ -0,0 +1,5 @@ +7..F.F7. +J.7.FJ|. +F.|SJJ.L7 +L..|F--J +...LJL.. diff --git a/2023/day10/t5 b/2023/day10/t5 new file mode 100644 index 0000000..c89317b --- /dev/null +++ b/2023/day10/t5 @@ -0,0 +1,5 @@ +7..F.F7. +J.F--JL7 +F.LS.J.|7 +L..|F--J +...LJL.. diff --git a/2023/day10/t6 b/2023/day10/t6 new file mode 100644 index 0000000..ed7f5b2 --- /dev/null +++ b/2023/day10/t6 @@ -0,0 +1,5 @@ +..F.F7. +.7.FJ|. +.|S---7 +..|F--J +..LJ... diff --git a/2023/day10/t7 b/2023/day10/t7 new file mode 100644 index 0000000..515214f --- /dev/null +++ b/2023/day10/t7 @@ -0,0 +1,7 @@ +.....--- +...F--7. +F7SJ..|. +..F-7||. +..|.L-J. +..L7.... +........