2024(6): add verbose bool and write idea for part two out
This commit is contained in:
28
2024/06/part2.py
Normal file
28
2024/06/part2.py
Normal file
@ -0,0 +1,28 @@
|
||||
from part1 import *
|
||||
|
||||
thoughts = \
|
||||
"""
|
||||
So, we can place an obstacle on each of the 130*130 - #obstacles = 16900
|
||||
- obstacles positions, but the initial path only covers 1512 positions
|
||||
(thus 1512 - 1 = 1511 steps). By instead placing an obstacle on each of
|
||||
those steps, we can find a loop.
|
||||
|
||||
The other thing we need to do, is detect loops. For that, It would be
|
||||
nice to store both positions and directions to establish uniqueness,
|
||||
or just check whether it is the fifth time in a position (as we have
|
||||
then travelled to that position at least twice from at least one
|
||||
position; see Pigeonhole principle).
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
m = Map()
|
||||
#m.load_map("testinput")
|
||||
m.load_map("input")
|
||||
|
||||
while m.step():
|
||||
# After each step, we can fork the map and add the obstacle.
|
||||
print(m.pos, m.direction)
|
||||
|
||||
#m.show()
|
||||
print(len(m.trace), m.trace)
|
||||
print(len(set(m.trace)))
|
||||
Reference in New Issue
Block a user