+/AoC
advent of code
git clone https://git.julia.blue/+/AoC
38c0746
master
1board = open ("input.txt" ).readlines () 2board .insert (0 ,' ' * len (board [0 ])) 3board .append (' ' * len (board [0 ])) 4board = [' ' + i + ' ' for i in board ] 5 6y = 1 7x = board [1 ].index ('|' ) 8ydir = 1 9xdir = 0 10steps = 0 11 12"Part 1: " , 13 14while board [y ][x ]!= ' ' : 15#print "pos:", x, y, "\t", board[y][x], "\tdir:", xdir, ydir 16steps += 1 17current = board [y ][x ] 18if current .isalpha (): 19'\b' + current , 20if not current in '|-' : 21temp = '|' 22if xdir == 0 : 23temp = '-' 24for tempdir in range (- 1 ,2 ,2 ): 25if board [y ][x + tempdir ]== temp : 26ydir = 0 27xdir = tempdir 28else : 29for tempdir in range (- 1 ,2 ,2 ): 30if board [y + tempdir ][x ]== temp : 31xdir = 0 32ydir = tempdir 33x += xdir 34y += ydir 35 36"\nPart 2:" ,steps