Skip to content

Commit

Permalink
Update part1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SpawnTerror committed Aug 9, 2023
1 parent 798c586 commit c157b78
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions day12/part1.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# SpawnTerror 2022
# Python 3.11.1
# AOC Day 12 Part 1

print('------------------------------------')
'''
Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi
[['Sabqponm'],
['abcryxxl'],
['accszExk'],
Expand All @@ -17,5 +19,64 @@
'''
with open("day12/test.txt") as f:
grid = [list(row.strip()) for row in f.readlines()]
totalLines = len(grid)
lineLength = len(grid[0])

def getStartCoordinates(grid):

totalLines = len(grid)
startPositionX = 0
startPositionY = 0

for lineNumber in range(0, totalLines):
for point in grid[lineNumber]:
if point == "S":
startX, startY = startPositionX, startPositionY
if point == "E":
goalX, goalY = startPositionX, startPositionY
startPositionY += 1
startPositionX += 1
startPositionY = 0

return startX, startY, goalX, goalY


def debug():
print(f'Start coords = ', startX, '-', startY)
print(f'Goal coords = ', goalX, goalY)
print(f'Total lines = ', totalLines)
print(f'Line length = ', lineLength)
print(f'Starting value = ',grid[startX][startY])
print(f'Ending value = ',grid[goalX][goalY])

def replaceWithNumbers(grid):
for n in range(0, totalLines):
for c in range(0, lineLength):
match grid[n][c]:
case 'S':
grid[n][c] = 0
case 'E':
grid[n][c] = 27
case other:
grid[n][c] = ord(grid[n][c]) - 96
return grid

startX, startY, goalX, goalY = getStartCoordinates(grid)
grid = replaceWithNumbers(grid)
#print(debug())
for line in range(0,totalLines):
print(grid[line])

value = 0
current = [grid[startX][startY]]

print(grid)
while True:
if value == 0:
break
# check right
if startX lineLength:
if current - grid[startX][startY+1] == -1:
startX +=1
value = grid[startX][startY+1]


0 comments on commit c157b78

Please sign in to comment.