day 7 part 1
This commit is contained in:
parent
1a4f2da0ce
commit
84fe8156a0
142
day07/input
Normal file
142
day07/input
Normal file
@ -0,0 +1,142 @@
|
||||
......................................................................S......................................................................
|
||||
.............................................................................................................................................
|
||||
......................................................................^......................................................................
|
||||
.............................................................................................................................................
|
||||
.....................................................................^.^.....................................................................
|
||||
.............................................................................................................................................
|
||||
....................................................................^...^....................................................................
|
||||
.............................................................................................................................................
|
||||
...................................................................^.^...^...................................................................
|
||||
.............................................................................................................................................
|
||||
..................................................................^.....^.^..................................................................
|
||||
.............................................................................................................................................
|
||||
.................................................................^.^.^.^.^.^.................................................................
|
||||
.............................................................................................................................................
|
||||
................................................................^.^.^...^.^.^................................................................
|
||||
.............................................................................................................................................
|
||||
...............................................................^.^.^.^.^.^.^.^...............................................................
|
||||
.............................................................................................................................................
|
||||
..............................................................^.^.^.^.^.....^.^..............................................................
|
||||
.............................................................................................................................................
|
||||
.............................................................^.^.^.^.^.^.^.^.^.^.............................................................
|
||||
.............................................................................................................................................
|
||||
............................................................^.^.....^.^.^.^.^.^.^............................................................
|
||||
.............................................................................................................................................
|
||||
...........................................................^...^.^...^.^.^...^.^.^...........................................................
|
||||
.............................................................................................................................................
|
||||
..........................................................^.^.^.^.^.^...^.^.^...^.^..........................................................
|
||||
.............................................................................................................................................
|
||||
.........................................................^...^.....^.^...^.^.^.^.^.^.........................................................
|
||||
.............................................................................................................................................
|
||||
........................................................^.^...^.^...^.^.^.^.^.^...^.^........................................................
|
||||
.............................................................................................................................................
|
||||
.......................................................^...^.^...^.^...^.^...^.....^.^.......................................................
|
||||
.............................................................................................................................................
|
||||
......................................................^...^...^.^...^.^.^.^.^.^.^.^...^......................................................
|
||||
.............................................................................................................................................
|
||||
.....................................................^.^.^.^.^.^.^...^.^.^.^...^.^.^.^.^.....................................................
|
||||
.............................................................................................................................................
|
||||
....................................................^.^.^...^.^...^.^...^.^.^.^.^.^.^...^....................................................
|
||||
.............................................................................................................................................
|
||||
...................................................^.^.^.^.^.^.^...^.^.^.^.^.^.....^.^.^.^...................................................
|
||||
.............................................................................................................................................
|
||||
..................................................^.^...^.^.^.....^...^...^.^...^.^...^...^..................................................
|
||||
.............................................................................................................................................
|
||||
.................................................^.......^.^.^.....^.^.^.^.^.^.^.^...^...^.^.................................................
|
||||
.............................................................................................................................................
|
||||
................................................^...^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^................................................
|
||||
.............................................................................................................................................
|
||||
...............................................^.^.....^.^.^.^...^.^.^.^.^...^...^...^.^.....^...............................................
|
||||
.............................................................................................................................................
|
||||
..............................................^...^...^.^.^...^...^.....^.^.......^.....^.....^..............................................
|
||||
.............................................................................................................................................
|
||||
.............................................^.^.^.....^.^.....^.^.....^.......^.^.^.^.^.^.^.^.^.............................................
|
||||
.............................................................................................................................................
|
||||
............................................^.^.....^.^.^.........^.^...^.^...^...^.^.^.^...^...^............................................
|
||||
.............................................................................................................................................
|
||||
...........................................^.^.....^.......^.^.^...^.^.^.^.^.^.^.....^...^.^...^.^...........................................
|
||||
.............................................................................................................................................
|
||||
..........................................^.^.....^.^.^.^...^.^...^.^.^.^.^.^.^.....^.^.^...^...^.^..........................................
|
||||
.............................................................................................................................................
|
||||
.........................................^.^.....^.^.......^.........^.^.^.^...^.^.^.^...^.^.....^.^.........................................
|
||||
.............................................................................................................................................
|
||||
........................................^.^.^.^...^...^...^.^.^.^.^.^.^.^.^.^...^.....^.^.^.^.^.^...^........................................
|
||||
.............................................................................................................................................
|
||||
.......................................^.....^.^.^.......^.^...^.....^.^.^...^...^.^.^.^.^.^.^.^.^...^.......................................
|
||||
.............................................................................................................................................
|
||||
......................................^.^.....^...^.^.^.^.^...^.^.^.....^.^.....^.^.^.^.^...^.^.^.^...^......................................
|
||||
.............................................................................................................................................
|
||||
.....................................^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^...^.^.........^.^.^.....................................
|
||||
.............................................................................................................................................
|
||||
....................................^.^.^.^.^.^.^.^.^.....^.^.^...^...^...^.^.....^.^.^...^.^...^...^.^.^....................................
|
||||
.............................................................................................................................................
|
||||
...................................^.^.....^.^.^...^...^.^...^...^.......^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...................................
|
||||
.............................................................................................................................................
|
||||
..................................^.^.^.^.^.^.^.^.^.^...^.^...^...^.^.^.^.^.^.^.^.....^.^.^...^.....^.^...^..................................
|
||||
.............................................................................................................................................
|
||||
.................................^.^.^.^.......^...^.^.^...^.^.^.....^.^...^.^.^.^...^.^.^.^...^.^.^.^...^.^.................................
|
||||
.............................................................................................................................................
|
||||
................................^.^.^.........^.^...^.^...^.^.^.^.^...^.^...^.^.....^...^.^.^...^...^.^...^.^................................
|
||||
.............................................................................................................................................
|
||||
...............................^.....^.^.....^.^.^.^.....^.^.^.^.^.^.^.^.^.....^.....^.^...^.....^.^.^.^.^.^.^...............................
|
||||
.............................................................................................................................................
|
||||
..............................^.^.^.^.^.^.....^.^.^.^.^.....^.^.^.^.^.^.....^...^.^...^.^.^.^.^.^.^...^.^.^...^..............................
|
||||
.............................................................................................................................................
|
||||
.............................^...^...^.^.^.^...^.^.......^.^...^...^.^...^.^.^.^...^...^.^.^.....^.^.^...^.^.^.^.............................
|
||||
.............................................................................................................................................
|
||||
............................^...^.^...^.^.^.^...^.^...^...........^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^...^.....^.^.^............................
|
||||
.............................................................................................................................................
|
||||
...........................^.^...^.^.^...^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^...........................
|
||||
.............................................................................................................................................
|
||||
..........................^.^.^...^.^...^.^.^...^...^.^.^.^.^...^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...^.^.^.....^.^.^..........................
|
||||
.............................................................................................................................................
|
||||
.........................^...^...^.^.^.^.^...^...^.......^.^...^.^...^.^.^...^.^.^.^...^.^.^.^...^.^...^.^...^.^.^.^.........................
|
||||
.............................................................................................................................................
|
||||
........................^.^.^.^.^.^.^...^...^.^.^...^.^.^.^.^.^...^...^...^.^.^.....^.^...^.^...^.^.^.^.^.......^.^.^........................
|
||||
.............................................................................................................................................
|
||||
.......................^.^.^.^.^.^.^.^.........^.^.^.^...^.^...^...^.^.^.^.^...^.^...^.^.^...^...^.^.^.^...^.^.^.^...^.......................
|
||||
.............................................................................................................................................
|
||||
......................^.^.^.^.......^.^.^.^.^...^...^...^.^.^...^.....^.^.^...........^.^.^.^.^...^.^.^.^.^.^.^...^.^.^......................
|
||||
.............................................................................................................................................
|
||||
.....................^.^.^...^...^...^.........^...^.^...^.^.^...^.^.^.^...^.^.^...^.^...^...^...^...^.^.^.....^.^.^...^.....................
|
||||
.............................................................................................................................................
|
||||
....................^.^.^.....^.^.^...^...^.^.^.^.^.^.^.^.^.^.^.....^...........^...^.^.^.^.^.^.^...^.....^.^...^...^.^.^....................
|
||||
.............................................................................................................................................
|
||||
...................^.....^.....^.......^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^.......^...^.^.^...^.^.^.^.^.^.^.^.^.....^.^...^...................
|
||||
.............................................................................................................................................
|
||||
..................^.^.^...^.^.^.^.^...^.^.^...^.^.^.^.^.^.^.^.^...^.^.^.^.^...^...^...^.^.^.^.^...^.^...^...^.^.^...^...^.^..................
|
||||
.............................................................................................................................................
|
||||
.................^.^.^.^.^.^...^.^.^.^.^.^...^.^.^.^.^...^.......^...^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^.^.^...^...^.^.^.................
|
||||
.............................................................................................................................................
|
||||
................^...^.^.^.^.^...^...^.^...^...^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^...^.^.^.^.^.....^.^.^.^.^.^................
|
||||
.............................................................................................................................................
|
||||
...............^.....^.^.^.^.^.......^.^.^...^.^.^.^.^.^...^.^.^.^.^.....^.^.^.....^.^.^.^...^.....^.^.^...^.^...^.^.^.^.^...^...............
|
||||
.............................................................................................................................................
|
||||
..............^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.......^.^.^.^.....^...^.........^.....^...^.^.^.^.^...^.^.^.^.^..............
|
||||
.............................................................................................................................................
|
||||
.............^.^.^...^.....^.....^...^.^...^.^...^.^.^.^.^.^.^.^...^.^.^...^.^...^.....^.^.^.^.^.^...^.^...^.^...^.^.^.^.^.....^.............
|
||||
.............................................................................................................................................
|
||||
............^.^.^...^.^.^.^.^.^.^...^.^...^...^.^.^.^.^.^...^...^.^.^.^...^.^.^.^.....^.....^.^...^...^...^.^.^.^.^.^.......^.^.^............
|
||||
.............................................................................................................................................
|
||||
...........^...^.^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^...........^.^...^.^...^...^.^.^.^.^.^...^.....^.......^.^.^.^...^...^.^...........
|
||||
.............................................................................................................................................
|
||||
..........^.^.^.^...^...^...^.^.^.....^.^...^.^.^.^...^.^...^.^.^.^...^.^.....^.^...^.^.^.^...^.^.^.^.^...^...^.^.^.^.^.^...^.^.^.^..........
|
||||
.............................................................................................................................................
|
||||
.........^.....^...^.^...^.^.^.^.^.^.^...^.^...^.^.^.^.^...^...^.......^.^...^.^.^.^.^.^.^.....^...^.....^.^.^.^.^.^.^.^.^...^.^.^.^.........
|
||||
.............................................................................................................................................
|
||||
........^.^.^.^.^...^...^.^.^...^.^.^.^...^.^.^.^...^.^...^.^.^.^.....^.^.^.^.....^.^.^.....^.^.^.^...^.^...^.....^.^.^.^.^.^...^.^.^........
|
||||
.............................................................................................................................................
|
||||
.......^.^.......^.....^.^.^.^...^.^.^.^.^...^.....^.^.^.^.^.^.^.^.^.^...^.....^...^.^...^.^.^.^...^.^.^.......^.^...^.........^.^.^.^.......
|
||||
.............................................................................................................................................
|
||||
......^.^...^.....^.^.^.^...^.^.^.^.^.^...^.......^.....^.^.....^.^.^...^.^.^.^...^.^.^.^.^...^.^.^.^.^...^.^.^.^.....^.....^.^.^.^.^.^......
|
||||
.............................................................................................................................................
|
||||
.....^.^.^.^.....^...^.^.^.^.^.....^...^.^...^.^.^.^...^.^.^.....^.^...^...^.^.^.^.....^.^.......^...^...^.^.......^.....^.^...^.^.^.^.^.....
|
||||
.............................................................................................................................................
|
||||
....^.^.....^.^.^.^...^.^.....^.....^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^...^.^.^.^...^.^.^.^.^.^...^...^...^.^.^...^.....^...^...^...^.....^....
|
||||
.............................................................................................................................................
|
||||
...^...^.^.^.^.^...^...^.^.^.^.^...^.^.^...^.^.^.^...^...^.^.^.^...^...^...^...^.^.^.^.^.........^.....^...^.^...^.........^.^.^...^...^.^...
|
||||
.............................................................................................................................................
|
||||
..^.^.....^.^.^.......^...^.^.^...^.^.....^.^...^.^...^.....^.^.....^.^.^...^...^.^.^...^.^.....^.....^...^...^.^.^...^.^.^.^.^...^.^.^.^.^..
|
||||
.............................................................................................................................................
|
||||
.^.^.^.^.^.^.^...^.^...^.^...^.^.....^.....^.^.^.^.^.^.^.^.^...^.^...^...^.....^.^.^.^.^...^.^.^.^...^.^.^.^.^.^.......^.^...^.^.^.^.^...^.^.
|
||||
.............................................................................................................................................
|
||||
16
day07/sample
Normal file
16
day07/sample
Normal file
@ -0,0 +1,16 @@
|
||||
.......S.......
|
||||
...............
|
||||
.......^.......
|
||||
...............
|
||||
......^.^......
|
||||
...............
|
||||
.....^.^.^.....
|
||||
...............
|
||||
....^.^...^....
|
||||
...............
|
||||
...^.^...^.^...
|
||||
...............
|
||||
..^...^.....^..
|
||||
...............
|
||||
.^.^.^.^.^...^.
|
||||
...............
|
||||
25
day07/sol.py
Normal file
25
day07/sol.py
Normal file
@ -0,0 +1,25 @@
|
||||
def solve(input):
|
||||
splits = 0
|
||||
pos = []
|
||||
for row in open(input):
|
||||
row = row.strip()
|
||||
next = []
|
||||
for i in pos:
|
||||
if row[i] == '.':
|
||||
next.append(i)
|
||||
elif row[i] == '^':
|
||||
if i-1 >= 0:
|
||||
next.append(i-1)
|
||||
if i+1 < len(row):
|
||||
next.append(i+1)
|
||||
splits += 1
|
||||
start = row.find('S')
|
||||
if start >= 0:
|
||||
next.append(start)
|
||||
|
||||
pos = sorted(set(next))
|
||||
|
||||
print(splits)
|
||||
|
||||
solve("sample")
|
||||
solve("input")
|
||||
Loading…
x
Reference in New Issue
Block a user