Compare commits
2 Commits
ee28498264
...
aaca415d2b
Author | SHA1 | Date | |
---|---|---|---|
aaca415d2b | |||
b05379719f |
@ -78,62 +78,83 @@ while not found:
|
|||||||
x = cur[1]
|
x = cur[1]
|
||||||
|
|
||||||
sub_found = False
|
sub_found = False
|
||||||
print('Start: ' + str(cur) + ' ' + wall(cur))
|
#print('Start: ' + str(cur) + ' ' + wall(cur))
|
||||||
|
|
||||||
dirc = ''
|
dirc = ''
|
||||||
|
|
||||||
print('Trying to find way')
|
#print('Trying to find way')
|
||||||
print('Previous is ' + str(prev) + wall(prev))
|
#print('Previous is ' + str(prev) + wall(prev))
|
||||||
if y+1 < len(grid[0]) and not sub_found:
|
if y+1 < len(grid[0]) and not sub_found:
|
||||||
|
#print('Can go right')
|
||||||
# Right
|
# Right
|
||||||
new = (list(cur)[0]+1,list(cur)[1])
|
new = (list(cur)[0]+1,list(cur)[1])
|
||||||
|
#print(wall(new))
|
||||||
if grid[x][y+1] in ('─','┐','┘') and new != prev:
|
if grid[x][y+1] in ('─','┐','┘') and new != prev:
|
||||||
print('Trying Right')
|
#print('Trying Right')
|
||||||
print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
#print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
||||||
dirc = 'R'
|
dirc = 'R'
|
||||||
if wall(cur) in ('─','┌','└','S'):
|
if wall(cur) in ('─','┌','└','S'):
|
||||||
print('Went Right')
|
if wall(new) == 'S':
|
||||||
|
print('Found')
|
||||||
|
found = True
|
||||||
|
#print('Went Right')
|
||||||
prev = (y,x)
|
prev = (y,x)
|
||||||
y += 1
|
y += 1
|
||||||
|
print(wall(new))
|
||||||
sub_found = True
|
sub_found = True
|
||||||
else:
|
|
||||||
print('Cant go right cus ' + str(y) + ' < ' + str(len(grid)))
|
|
||||||
|
|
||||||
if y > 0 and not sub_found:
|
if y > 0 and not sub_found:
|
||||||
|
#print('Can go left')
|
||||||
# Left
|
# Left
|
||||||
new = (list(cur)[0]-1,list(cur)[1])
|
new = (list(cur)[0]-1,list(cur)[1])
|
||||||
if grid[x][y-1] in ('─','┌','└') and new != prev:
|
if grid[x][y-1] in ('─','┌','└') and new != prev:
|
||||||
print('Trying Left')
|
#print('Trying Left')
|
||||||
print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
#print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
||||||
dirc = 'L'
|
dirc = 'L'
|
||||||
if wall(cur) in ('─','┐','┘','S'):
|
if wall(cur) in ('─','┐','┘','S'):
|
||||||
print('Went Left')
|
if wall(new) == 'S':
|
||||||
|
print('Found')
|
||||||
|
found = True
|
||||||
|
#print('Went Left')
|
||||||
|
prev = (y,x)
|
||||||
y -= 1
|
y -= 1
|
||||||
|
print(wall(new))
|
||||||
sub_found = True
|
sub_found = True
|
||||||
else:
|
|
||||||
print('Cant go left cus ' + str(y) + ' > ' + str(0))
|
|
||||||
|
|
||||||
if x > 0 and not sub_found:
|
if x > 0 and not sub_found:
|
||||||
|
print('Can go up')
|
||||||
# Up
|
# Up
|
||||||
new = (list(cur)[0],list(cur)[1]-1)
|
new = (list(cur)[0],list(cur)[1]-1)
|
||||||
if grid[x-1][y] in ('│','┌','┐') and new != prev:
|
#print(wall(new))
|
||||||
|
if grid[x-1][y] in ('│','┌','┐','S') and new != prev:
|
||||||
print('Trying Up')
|
print('Trying Up')
|
||||||
print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
||||||
dirc = 'U'
|
dirc = 'U'
|
||||||
|
|
||||||
if wall(cur) in ('│','└','┘','S'):
|
if wall(cur) in ('│','└','┘','S'):
|
||||||
print('Went Up')
|
print('Went Up')
|
||||||
|
if wall(new) == 'S':
|
||||||
|
print('Found')
|
||||||
|
found = True
|
||||||
|
prev = (y,x)
|
||||||
x -=1
|
x -=1
|
||||||
sub_found = True
|
sub_found = True
|
||||||
|
|
||||||
if x < len(grid) and not sub_found:
|
if x < len(grid) and not sub_found:
|
||||||
|
#print('Can go down')
|
||||||
# Down
|
# Down
|
||||||
new = (list(cur)[0],list(cur)[1]+1)
|
new = (list(cur)[0],list(cur)[1]+1)
|
||||||
if grid[x+1][y] in ('│','└','┘') and new != prev:
|
#print(wall(new))
|
||||||
print('Trying Down')
|
if grid[x+1][y] in ('│','└','┘','S') and new != prev:
|
||||||
print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
#print('Trying Down')
|
||||||
|
#print('prev: ' + str(prev) + ' cur: ' + str(cur) + ' new: ' + str(new))
|
||||||
dirc = 'D'
|
dirc = 'D'
|
||||||
if wall(cur) in ('│','┌','┐','S'):
|
if wall(cur) in ('│','┌','┐','S'):
|
||||||
print('Went Down')
|
#print('Went Down')
|
||||||
|
if wall(new) == 'S':
|
||||||
|
print('Found')
|
||||||
|
found = True
|
||||||
|
prev = (y,x)
|
||||||
x += 1
|
x += 1
|
||||||
sub_found = True
|
sub_found = True
|
||||||
|
|
||||||
@ -141,13 +162,13 @@ while not found:
|
|||||||
cur = (y,x)
|
cur = (y,x)
|
||||||
|
|
||||||
steps.append((x,y))
|
steps.append((x,y))
|
||||||
|
p(grid,steps)
|
||||||
print('Going ' + dirc + ' to ' + str(cur) + ' ' + wall(cur))
|
print('Going ' + dirc + ' to ' + str(cur) + ' ' + wall(cur))
|
||||||
print('Previous is ' + str(prev) + ' ' + wall(prev))
|
print('Previous is ' + str(prev) + ' ' + wall(prev))
|
||||||
p(grid,steps)
|
|
||||||
print()
|
print()
|
||||||
input()
|
input()
|
||||||
count += 1
|
count += 1
|
||||||
if cur == start:
|
#print(cur, start)
|
||||||
found = True
|
p(grid,steps)
|
||||||
|
|
||||||
print(count)
|
print(count)
|
||||||
|
print(count/2)
|
||||||
|
5
2023/day10/t3
Normal file
5
2023/day10/t3
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
..F.F7.
|
||||||
|
.7.FJ|.
|
||||||
|
.|SJ.L7
|
||||||
|
..|F--J
|
||||||
|
..LJ...
|
5
2023/day10/t4
Normal file
5
2023/day10/t4
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
7..F.F7.
|
||||||
|
J.7.FJ|.
|
||||||
|
F.|SJJ.L7
|
||||||
|
L..|F--J
|
||||||
|
...LJL..
|
5
2023/day10/t5
Normal file
5
2023/day10/t5
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
7..F.F7.
|
||||||
|
J.F--JL7
|
||||||
|
F.LS.J.|7
|
||||||
|
L..|F--J
|
||||||
|
...LJL..
|
5
2023/day10/t6
Normal file
5
2023/day10/t6
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
..F.F7.
|
||||||
|
.7.FJ|.
|
||||||
|
.|S---7
|
||||||
|
..|F--J
|
||||||
|
..LJ...
|
7
2023/day10/t7
Normal file
7
2023/day10/t7
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.....---
|
||||||
|
...F--7.
|
||||||
|
F7SJ..|.
|
||||||
|
..F-7||.
|
||||||
|
..|.L-J.
|
||||||
|
..L7....
|
||||||
|
........
|
Loading…
Reference in New Issue
Block a user