Compare commits
3 commits
6ad529cd31
...
3e62d78bc5
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e62d78bc5 | |||
| e26fc98af0 | |||
| 2fe4311e10 |
8 changed files with 1601 additions and 0 deletions
10
day4/input0.txt
Normal file
10
day4/input0.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
..@@.@@@@.
|
||||||
|
@@@.@.@.@@
|
||||||
|
@@@@@.@.@@
|
||||||
|
@.@@@@..@.
|
||||||
|
@@.@@@@.@@
|
||||||
|
.@@@@@@@.@
|
||||||
|
.@.@.@.@@@
|
||||||
|
@.@@@.@@@@
|
||||||
|
.@@@@@@@@.
|
||||||
|
@.@.@@@.@.
|
||||||
140
day4/input1.txt
Normal file
140
day4/input1.txt
Normal file
|
|
@ -0,0 +1,140 @@
|
||||||
|
@.@...@@@....@@@@@@@.@@@.@..@@@@@@@@.@@@@@@@@.@.@@@@@@.@@@@@@@@.@@.@.@@@@.@@.@.@...@@@@@@@.@.@.@.@@@@@.@@.@@.@.@@@@@@@@@@@@@@...@@@@.@.@@...
|
||||||
|
@.@.@@@@.@.@.@@.@@@@@..@.@@.@@@...@@@...@.@@.@.@@...@...@@.@@@@..@.@..@.@....@@.@@@.@.@@@@...@.@.@.@..@@@.@...@....@...@@.@@@...@.@@@@@@@@@@
|
||||||
|
@.@@@@@@.@.@@.@@.@@..@@.@@.@@..@@@.@.@@..@@.@.@.@@@@.@@@@@.@@@@.@..@.@.@.@@.@@.@..@.@@@.@..@@@@@@.@..@@@@@.@@...@.@@@@@@@@.@@@@@@@@@.@@@.@@@
|
||||||
|
@@@@@@@@@@@....@@@..@.@@@@@@..@@..@@.@..@.@@@@@@@@@..@@@@@@..@.@.@.@@@@@@.@@@..@@@@.@.@@@@@@@@@.@.@@..@@.@@@@....@@...@@.@..@.@@@.@.@@@@@...
|
||||||
|
@@@..@.@@@@@@@...@@.@.@...@.@.@@.@@@@.@...@@@.@.@@.@@...@....@.@@@@@..@@.@@..@@..@@..@@...@@..@@@@@@@@.....@..@@@..@@@.@@@.@@@.@.@...@@.@@@@
|
||||||
|
.@@.@.@@@.@.@@@@@..@@@.@.@@.@......@@..@..@@@@@@@@..@@.@.@.@@.@.@@...@.@@@@...@@.@..@@.@@@@.@@..@.@.@@.@@.@@.@@@..@@.@@@@@@@..@@@@@@@.@@@@..
|
||||||
|
@..@@.@@..@.@.@@@..@@@@.@@@@@@.@.@@....@@@@.@@@@.@.@.@@.@@@@..@@..@.@.@@@...@.....@@@@@.@@@.@.@@@..@..@@@..@@@@@@..@@@@@@..@.....@..@.@...@.
|
||||||
|
..@@@@..@.@@..@.@@.@@@.......@.@@@@..@.@.@@@@@@@..@..@@@@.@.@@@@..@.@..@@@@@@.@@@.@.@.@@@.@@.@@.@@@@..@@@@..@@@.@@......@@@@@.@@...@@.@..@@@
|
||||||
|
.@@@..@.@@@@@@@@@@..@.@@@@@.@@.@@@@@@..@.@.@.@@@.@@.@..@@@@@@@@@.@.@@@@.@@@@.@....@.@..@@.@.@..@.@..@..@@@.@@.@..@@.@@..@@@@@.@..@@@@@.@@@@@
|
||||||
|
@.@@..@@.@.@@@@@.@@.@@@..@@@@.@.@@@@@@.@@.@@@..@@@.@@.@@@@@@@.@@@@.@@@.@@.@.@..@.@.@@..@@.@..@@@@@@@@@@.@@..@.@..@@@@@@@@.@@@@@.@.@@@@@@@.@@
|
||||||
|
.@@@@..@@..@@@.@.@@..@..@.@@..@@.@.@.@..@@@@@.@@@@@.@@..@.@@.@@@..@@@@@@....@@.@@@@@.@@@.@@@.@@@@@@.@@@..@@@@@.@.@@@@@@@@..@@..@@..@.@.@@@@.
|
||||||
|
@@@@.@@@@@.@@@@.@@...@@.@.@..@@@.@.@....@.@@@@....@...@@@@@@@.@.@@@@.@@@@...@.@.@.@@@@@@@..@@@@@.@@.@@..@.@@.@.@...@..@.....@...@@@@.@@@.@@@
|
||||||
|
....@@.@...@@@..@@@@@@@@..@@@@@....@..@@@@@@@@@@@@@@.@.@.@.@.@@@@@@@@.@@@@@@@@@@@@.@@.@@.@..@@..@.@@@.@@@@.@@@@@@@@@@@@@@@@@.@..@@@@@@@@@@@@
|
||||||
|
@@@@@@@.@@...@@@@@@..@@@.@@.@@.@@@..@@@@@@@@@..@@..@@..@@.@@@@@@.@.@@...@.@...@.@@.@..@@..@.@.@@@@.@@@@@.@@@@@.@@.@@.@@....@...@.@.@.@@@..@@
|
||||||
|
@@@.@.@...@@..@@.@..@..@@.@@.@@@@.@@@@@@@@@@@@@.@@...@@...@@.@@@@@..@@..@.@@@@@.@@@@@...@@.@.@@@..@@@@@@@.@.@@@@@.@@@.@@@@@.@.@@@@@@.@.@..@@
|
||||||
|
.@@..@@@@@...@@.@.@@@@..@@@.@.@...@@@..@@@@.@@@@.@@@@@.@@@@@@@.@@@.@.@@.@.@...@@@.@@@@@@..@@@@@@@@@...@@.@@@..@@..@@.@.....@@@@@.@@@.@@..@@.
|
||||||
|
@@.@..@@@...@@@@@@.@..@@@@.@..@.@@.@@@.@@@@.@..@.@@@@@@@@@@...@@....@@@@.@@..@@.@@@..@@@.@@@...@@.@.@@@.@@.@@@@@..@@.@..@...@@..@@@@@@.@.@..
|
||||||
|
@@.@.@@@..@..@....@@@@@@@@.@@@..@@.@...@@..@@@@@@@.@@@@@@.@.@@@..@@@..@@@...@.@.@@@@...@@@@.@@@@.@@.....@.@.@@..@@@..@@.@@@@@.@@@@@.@@@@.@@.
|
||||||
|
@@@.@@@@@@@@@@@@@@@@@.@@.@@@@..@@.@.@@.@.@...@.@@@@@@.@@@@@@@@@@@@@@@.@@.@@@@@@@.....@@..@@.@.@..@@@@......@..@..@.@.@@@@@...@@@@..@@.@.@.@@
|
||||||
|
.@@@@@@@.@..@@@.@.@@@..@@@.@@@@@@.@.@@@@@@.@@@@..@@@@.@@.@@.@.@.@@@...@@..@.@@....@@@@...@@.@..@@.@@@..@@.@.@@@@.@@@@@..@.@.@.@@@@.@@.@@@@.@
|
||||||
|
@@.@@...@.@@@..@@@@@.@@@@.@@@.@@@@@..@@.@@.@@@@@@.@@@@.@....@@@.@..@@.@.@@@..@@@@@@...@@@@@@.@@@..@@.@@@@@@@..@@...@@@@@@@@.@.@@..@@.@.@@.@.
|
||||||
|
@@@@...@@.@@@.@..@@@@.@@..@@..@..@@@@@.@@@@.@@@@@.@@@@@@@.@..@@@.@.@.@@@.@@@@@..@@@.@..@@..@@.@@.@.@.@@...@@@@@..@.@@@@.@@@@.@.@@..@.@..@@@.
|
||||||
|
.@@@@@..@@.@.@@.@@@@..@@@@.@@@@..@@.@..@@....@.@.@@@@@@@@@@@@@@@@....@@@.@.@.@@@@@@@@@@@..@@@.@.@@@@@@@@@@@.@..@.@@@@@@.@@@@..@@@@..@.@@.@@.
|
||||||
|
..@@.@@@..@@@@....@@..@@.@.@@.@.@@.@.@@@.@@@.@@@@@@...@.@@.@@@.@..@.@..@@......@@@@..@@....@..@.@.@@@..@@@@.@@@@@@@@@..@@@@@.@@@@.@.@.@@...@
|
||||||
|
@@@@@@@.@@..@.@.@@@.@@@..@.@@@...@@@@.@.@@@@@@@.@@@@@.@..@@@@..@@@.@@@@@@.@@@@.@@.@..@.@.@@@@@.@@.@.@@@..@@.@.@@@.@@@@.@.@@@@.@..@.@@@@@..@@
|
||||||
|
@@@@.@@@@@@@@.@.@..@@@@@.@@@@.@...@@@@@@@.@@@.@@@@@@@.@@...@@@@.@@@@@@@..@@@@.@@@...@@.@....@@.@.@.@.@@@@.@@@@.@@@@@....@.@.@@@.@@@@@@.@@@@@
|
||||||
|
@@@@@@...@.@@.@..@@@@..@@@@.@@@@@..@@@@@.@..@@...@@@..@.@@@@@.@..@@@@......@..@.@@@@.@@@@@.@@@.@@@.@@@.@@@@..@.@.@....@@.@.@@.@@@.@@@@@@@@@@
|
||||||
|
.@@@@.@.@@@@@@@@@.@..@@@@@@@@.@@@.@@@.@.@@@@@@@..@@@@@@.@@@.@@.@.@@@.@@.@.@.@@.@@@@.@@.@@@.@.@@@@@@@@.@@@@@@@@@@@@..@@@@.@@..@@...@@.@@@.@@.
|
||||||
|
@@@@.@@..@@.@@@@@.@.@.@...@..@@@.@.@@.@@@@...@.@..@@@...@@@.@.@.@@@@.@.@@@..@@@@@@@@.@@@..@.@.@@@.@@...@.@.@@.@@@@@.@.@@@@@.@@.@@@@@.@.@..@@
|
||||||
|
@@@@@@@@@@@.@...@@@@.@.....@@.@@.@@.@@.@.@@@@@@@@@@.@.@.@@@.@@@.@.@.@.@.@.@.@..@@@@@@.@@.@.@.@@....@..@@@@@@@.@@..@@@.@..@@@.@@@@.@@@@@@.@..
|
||||||
|
@@...@....@.@@.@..@@..@@@...@@@@...@@@.@@@@@@@.@..@....@@.@@.@.@.@@@@@@@@@.@@...@@@@@@@.@.@..@...@@@@@@..@.@@..@@@.@.@@.@@@@.@.@@.@@..@.@@@@
|
||||||
|
.@..@...@@@..@@..@@...@@@@@.@@@.@@.@@.@.@.@@.@@@@@...@..@@@..@@@@.@@.@@@....@@@.@@.@@@..@@.@@@@..@@.@..@@@.@@..@@.@@.@.@@@..@@.@@..@@.@@@@.@
|
||||||
|
..@@@@@@@@@@.@..@.....@@@@@.@.@@@@@@@@@@@.@...@.@@.@.@@@@.@..@@.@@@..@@@@..@@@@@@@@.@@@.@@.@.@@@@...@.@.@..@@@@.@.@@@@..@@@@.@.@@@@..@@.@@@.
|
||||||
|
..@@@@.@@@@@@@@...@@@@@.......@.@@@@@@..@...@..@..@.@@@.@@.@.@@.@@..@.@.@.@@.@@.@..@@@..@.@.@.@@@.@@..@@@@@@..@@@.@@@.@@@@..@@.@.@@@@@...@@@
|
||||||
|
@...@@@@.@@@@@.@..@@@.@@@@...@@@@..@..@@@.@@@..@@@@@.@@@.@@@@@@..@.@@.@..@@.@@@@.@@@@@@@@..@@@@@@@.@...@.@@@@.@.@@.@@.@@@@.@.@..@@..@.@@.@@@
|
||||||
|
@@.@@..@@@.@@..@.@@@@@@.@.@@.@@..@.@..@@@@@.@@@@@@.@@@@@@..@@@..@.@@@@@@@@@@.@..@@@@@.@.@@.@@@@@@.@..@.@@.@@.@..@@@.@@..@@@.@@@@@.@@.@.@@@.@
|
||||||
|
.@@@@..@@@@@@@@...@@.@.@@@@..@@@@.@@...@@@@@@..@@..@.@.@.@@@...@@@@@.@@.@@.@@@@.@.@.@.@@.@.@.......@@@@@@@@.@@@@.@@.@@@.@@.@.@.@@@.@@.@@@@@@
|
||||||
|
@..@@.@@@..@...@@@..@@.@..@@@@.@..@@.@...@.@@@@.@@@..@@@.@@@..@.@@@..@@@@@@.@.@.@@.@.....@@@@....@@@@.@@@@.@@@@@@@@@@..@...@@@@@@@@.@@.@.@..
|
||||||
|
.@@@.@@@@..@.@@@..@@@..@@@.@.@..@@@..@.@@@@@@@@@..@.@.@@@@@.@..@@@@.@@.@..@@@..@..@.@.@@.@.@@@@.@@@.@..@@.@@@@...@.@.@@@@@@.@@@@@@.@@@@@@@@@
|
||||||
|
.@..@.@@@@@.@..@@@...@@.@@.@...@@@@@.@@@@@@.@@@....@.@.@@@@@.@..@@@@@@@@@@@@.@..@.@@@@.@@@@@@@.@@.@@.@....@@@@.@.@.@@@@@..@@@@@@..@..@..@.@@
|
||||||
|
@@..@.@..@@.@@@@@@@.@@@@@.@.@@.@@@@@.@.@...@@@.@@@@.@.@.@@.@.@@@@...@@@..@@.@@@@@@@@.@@@@.@@@.@@@.@@@@..@@.@@.@..@.@@@@.@.@..@@@@@@@@.@@@.@@
|
||||||
|
.@.@.@.@@@@@..@@@@@@@@.@@@@@.@@.@@@@@@.@@@@@@@@.@.@@@.@@@.@..@@@@..@@@@@..@@..@@.@@@@@.@@@@@@@.@@@@..@@@@@.@@..@@@.@@@@.@.@@@.@.@@@@.@@@@..@
|
||||||
|
.@@.@..@@@@..@@.@@@@@.@@..@@@@.@.@.@@.@@@@@.@@@.@@@..@@@@@..@@..@.@@.@@@@@@@.@@@...@@@@@.@.@..@@@.@@...@@.@@@@@@@@.@@....@.@.@.@..@@@@.@@@.@
|
||||||
|
@@@@@@..@@@@@..@@.@@@..@@.@....@..@@@@@.@.@@@..@.@.@.@@@..@@..@.@@@@.@..@@.@.@.@@@.@.@@@.@.@@@.@...@@@@@@@@@@@..@@@@@@@@.@@@@@@@@@@@@@@.@@.@
|
||||||
|
.@@@@.@@@@@.@@@@...@.@@@@@@...@@.@@..@@@@.@@@.@@@@@@@..@.@@@@@..@.@@@.@..@.@@..@..@.@@.@@@.@@@@@@@@@@@@..@@@@@@@@@@..@@@.@@.@..@.@@..@..@@@@
|
||||||
|
..@.@.@@@..@@.@@@@@@@.@@@@.@@@@@.@@@@@.@@@..@.@..@@...@@.@...@@..@@....@@@@.@@@@@.@@.@@.@@@@@..@@@..@@@@@@@@.@.@..@@.@@.@..@.@.@@..@.@.@.@@.
|
||||||
|
@@@@.@@...@.@.@.@.@@@@@..@@@@.@@.@@@..@@@.@.@@@@.@.@@...@.@@@@@@.@@.@@.@.@.@@@.@..@....@@.@@@@.@.@..@@@@@@@@.@.@..@@.@.@.@..@.@.@@@@@..@@@@@
|
||||||
|
.@@..@@..@@@@..@@.@@.@@@@.......@..@@...@@@.@@.@@@@@.@@@@@@..@...@@@..@@@@...@@...@@.@@.@..@@@@@.@@.....@@@@@..@@@@@@.@.@@..@@@@@@.@@.@@@..@
|
||||||
|
@@@.@@@.@@@@.@@@@@.@.@@..@@..@@.@.@.@..@@.@@.@@.@.@@@...@@@.@.@.@...@@@..@@.@@@..@@@@@.@.@@@@@@.@@@@@@@....@@.@.@@@@.@@.@.@@@@@@@@@@.@@@@..@
|
||||||
|
.@..@@@..@..@@..@@..@@@...@.@@.@@.@@@.@@.@@@.@@@@@@@@..@@.@@.@@.@@...@@...@@@.@@@.@@..@@@.@..@@@..@..@@@@@@@@..@@@@@@@@@.@@@.@.@@@..@@@...@@
|
||||||
|
@@@@...@@.@@.....@@@.@@@.@..@@.@@@@@.@..@.....@@@@@.@@@@.@@.@@@@.@@.@@@..@.....@@@@@.@@@.@.@..@.@@@@@@.@.@.@@@@.@@.@@.@@..@@@.@.@@@@@@@@@@@@
|
||||||
|
..@.@@.@@..@@@@@..@@@.@@..@.@.@...@.....@@@@@@@@@@@.@@@..@@@@@@@@@@...@@@@.@@..@@@@.@.@.@@.@@.@@.@@@@@.@@@.@@@.@@@.@.....@@@@.@@@.@....@@@@@
|
||||||
|
.....@@.@@@@@.@@@@.@.@@@.@@..@.@.@@@.@..@.@.@@@..@.@.@.@.@@@@@@@..@@.@@@@@@..@@.@..@.@..@@@@..@.@@@.@.@@@@@...@..@@..@.@@.@..@@.@.....@..@@.
|
||||||
|
.@@.@@@@...@...@...@.@@.@@..@@.@.@..@@.@@.@.@..@@..@..@@@@@@..@@@@.@.@.@@@@@@@@@@.@@@..@@@@@@.@.@..@@@@@@@@@@@@@..@@@@.@@..@.@@.@@..@..@@@@.
|
||||||
|
@..@@@@.@@.@...@@.@@.@.@@@...@@@@.@@.@.@@..@.@@@@@.@@@@@@..@@@.@@..@@...@@@@@@@@..@.@@@@@@@...@@@@.@@.@..@.@.@..@@..@@@@@@@....@.....@@@@.@.
|
||||||
|
@.@@@@@@@..@@.@.@@@@@.@@.@@...@@.@@.@.@..@@.@..@@@.@@..@..@@..@@.@..@..@@@.@@@@@@@@.@@....@.@@@....@@@@@@@@..@@@@@@@@.@@...@....@...@.@.@.@.
|
||||||
|
.@@@@.@@.@@@@@@@@.@@@.@@@@....@@@@.@@.@@@....@@@@.@@@@@@.....@@@.@@.@.@@@.@@..@@@@@@@@@.@...@@@@@@@@..@@.@@..@@@@@@@@@@....@@@.@..@@@.@@.@.@
|
||||||
|
@..@@.@.@@.@..@.@.@..@@@..@..@@...@.@@@@@@@@@@@...@@@.@@@.@@.@@@@@@.@@@.@.@@@..@....@@@.@.@@@@@@@.@@...@@..@......@.@@..@..@.@@@.@@.@.@.@@@.
|
||||||
|
@.@.@.@@..@@.@@@.@@@...@@@...@.@.@@@.@@@..@.@@..@.@@@@..@@@@..@@.@..@@@..@@.@@.@@@@.@@@@@@.@@@.@@@...@.@.@@@...@.@@..@@..@@@@@@..@@.@.@.@@@.
|
||||||
|
..@@@.@.@@@@.@@.@@@@@@...@.@..@..@.@.@@.@@..@.@.@@..@@@@.@.@@@@@@@..@@.@.@@@..@@@.@...@@@@@@@@@@@@@.@.@@@@@@.@@.@@@@...@.@..@.@@@.@@.@..@@..
|
||||||
|
@.@.@..@@.@@@@@@@.@@@.@@@.@@@@@.@@@@@@@@.@.@@.@@..@..@@@@...@@@.@@@.@.@@@@@.@.@@@@@@.@@@@.@.@@.@...@@@@@@@@@.@@@.@.....@@@@..@.@@@@@..@@@@@@
|
||||||
|
@.@@.@@@..@@@.@@@@.@@@.@@..@@@@@@@...@@@.@@.@@@@@.@@..@@@@@@.@@@.@.@.@..@@@@.@.@@@.@@@@.@@.@@@@@@.@@.@@.@@@.@.@....@.@..@@.@@.@@@@@@@@@.@@@@
|
||||||
|
...@@.@..@@..@.@@@@@..@..@.@.@...@.@@@@@@.@@@@..@@@.@@.@.@.@.@@.@.@@@@@.@.@@@@@@@@@@@@@@.@@@.@@@.@@@@@.@@@.@@@@@.@@.@.@.@@.@@..@@@@.@@.@.@@@
|
||||||
|
@@.@@@@@@@@@.@@@@@.@@@.@@@......@@.@@@@@..@@.@...@@...@@@@@@.@@@@.@@.@@.....@.@@@@@@..@@@.@@..@.@@@@@@.@..@..@@@...@@.@@@@@@.@@@@@@@.@@.@@..
|
||||||
|
@@@.@.@..@@@.@..@@@@@...@@...@@@.@@@@..@@@@.@@.@@@..@.@@@@@@.@@@@@@@@.@@@@@@..@@.@@@@.@@@@@....@@@@.@@..@@.@...@@.@.@@@@@@@@@.@@..@@..@@@@..
|
||||||
|
@@.@@.@.@@@..@..@@.@@@.@..@@..@@.@@@.@@@@.@..@@@..@@@@.@.@@......@@@@...@.@@@@@@@.@.@@.@.@......@..@@@@@@@.@.@.@.@..@@@...@@@.@@..@@.@@..@@@
|
||||||
|
@.@.@@@@@.@.@@@@@@@.@..@..@@...@@@@@@@@.@@@@@@@@.@@@.@..@.@@.@@.@@@.@.@@@@@.@@.@@.@....@@.@@@@..@@@.@.@.@@...@@..@..@@..@@@..@@@@@@@.@.@.@@.
|
||||||
|
...@.@@@@..@@@@...@.@@@.@@.@@@.@@@@.@@.@@@..@@.@@.@@@.@@..@@@@@@@@.@@@.@@@@.@.@.@.@@.@@.@.@@.@@..@@@@@@.@@@@@@@@@@@..@.@@@@.@...@.@@..@...@@
|
||||||
|
.@.@@@.@.@@.@..@@@@@..@@.@@@.@.@@@.@..@.@@@.@@@@@@@.@@@@@@..@@.@.@@@..@@@@@@@@@@@@@..@@...@@@@@@.@@@@..@@.@@@..@@.@@.@.@@@@.@@.@.@.@@.@@@@@@
|
||||||
|
@.@.@@...@@@@@@.@@@.@@@.@@@@@@@....@..@@@..@..@@..@@.@.....@@..@.@.@..@@@.@@@@@.@@.@@...@@@@@@.@.@.@...@.@@@@@....@@@.@.@@@....@@@.@@@.@@@.@
|
||||||
|
@@.@@@@.@@@@..@@@@@@@@@..@@.@..@.@@@@......@@@@@@@..@@.@@@.@@.@.@.@.@@@.@@.@@..@@@@.@.@@.@@.@@@@@.@.@@.@@@...@..@@@.@.@@@.@@@@@.@@@.@@@@...@
|
||||||
|
@..@...@.@.@.@@.@.@...@@.@.@.@@@@@@@.@@.@@..@@..@..@@.@@@.@@@.@@@.@.@@@@@@@@@@@.@@@@@@.@@@.@@@.@@@.@@..@@.@@@@@@@@.@@..@@@.@@.@.@@@@.@.@.@@.
|
||||||
|
@@@@@.@@..@@@.....@.@@.@@@@.@.@@@@@@@@.@@@...@@@@@@@@@.@@@.....@.@@@.@@@@.@@.@@@...@..@@@@@..@@@@@@@.@...@@@@@@@@@@@@@.@@@..@@@@.@.@..@.@.@@
|
||||||
|
@.@@@@@..@@@@@@@.@@.@....@@@@.@@@...@@@@@@..@@@@.@@.@..@@@@@.@@......@.@@@@@@....@@@@@@@@@.@@@@@.@...@.@@@.@..@@@....@@@@.@.@.@.@@@.@@@@@@..
|
||||||
|
@@@..@@@@@@@@.@@@..@@@@@@@@@@@@.@@.@@@@@@@..@.@@@.@.@.@.@.@@@.@@..@@.@...@@@.@@@.@@@@.@..@@.@@..@@@..@@.@.@@..@.@@@@@@@..@@@..@@@@...@....@@
|
||||||
|
.@@@@@..@@@@@@..@.@.@@@@@@@.@..@@.@.@..@@..@@@@.@.@...@.@.@@.@@@@@.@.@@@@@@@@.@.@...@..@@.@@@..@@@@@@@@..@.@@@@@.@@@.@@@@@@@@..@...@@.......
|
||||||
|
..@@@@..@.@@.@@..@.@.@@@@@..@@@@@@@..@@.@@.@@.@@.@@@.@@@@@@@@@..@@@@@@.@@@@...@@@@@..@@@@@...@.@@..@@.@.@@@@@@@..@.@@@@@@@@@.@@@.@..@..@.@..
|
||||||
|
@@@.@.@@@@.@@@.@@.@@@.@.@@@@@.@@@@@@.@@@....@@@@@@@@@.@@.@@@@@@@@@@@@.@..@@@@.@.@@@...@@@..@@@.@@@.@...@...@@.@@@@@@@...@..@@@.@@@.@@@.@@@..
|
||||||
|
@@@@@@@@@.@@@...@@@@..@....@@..@@@@@.@@@.@@@....@@@@@.@@..@@..@...@.@@@@@@.@@@.@@.@.@@.@.@..@@@@.@@..@....@.@..@.@.@.@@..@.@@@.@@@.@@@@@.@@.
|
||||||
|
...@@@@@.@@.@@@.@.@.@@@...@@.....@@@@@@@.@@@@@@...@@@.@...@@@@@@.@@@@@.@@@@.@@..@.@.@.@@.@@..@@......@.@.@.@@.@@.....@@@..@@@@.@@.@@@@.@.@@@
|
||||||
|
@@@@..@@.@.@@.@.@@@@@.@@@@..@@..@@@.@@...@@@@@@.@@@@@.@.@.@.@.@@@@@@@@.@.@..@.@@@.@@@@@@@@...@@.@@.@@.@@@@@@@@@@@@@.@@@@@.@@....@.@@@.@@@@.@
|
||||||
|
@.@@.@@..@@@@..@@@@@@@@..@...@@@..@@.@@..@@@@@@@...@.....@@.@@@@.@..@.@@@@.@.@.@@.@@@..@@@.@@@@@@@@@@@@@@...@.@@..@@@@@@@@@.@@@@....@.@@@@.@
|
||||||
|
@.@@@@....@@@@@.@@@@@.@@.@@...@@@.@@@.@@.@@@.@@@@...@@@@@@@@..@@@..@@@.@.@.@@.@@..@..@..@@@@.@@@@@.@@@@@.@..@.@@@.@@@@@.@@@.@..@@..@.@.@@.@@
|
||||||
|
..@.@@@@...@@...@@.@@@@@@@@.@@@...@@.@.@...@@@@.@@@@.@@@@.@@@..@@@@.@@.@..@@..@...@@@@@@@..@..@.@...@.@@@@@@@@@@.@....@@...@...@@@@.@@@.@@..
|
||||||
|
.@@..@.@..@@@@@@@@@@@.@@@@@...@@@.@.@.@@@@@@@@..@..@@..@.@@@@.@@..@..@.@@.@@@@@@..@@.@@.@@.@.@@@@@@@@@@@...@@@.@@@@..@.@...@@@.@...@.@@@@@@@
|
||||||
|
.@@@@@@@.@@@.@.@.@.@@.@.@@.@@@..@@@@@@@@@.@@@@@@@.@@@@@.@...@@@.@@..@.@.@.@..@.@@@.@.@.@....@...@.@.@@@.@@@@.@.@@@.@..@@@.@..@.@@@.@@...@.@.
|
||||||
|
.@@...@@.@@@@.@....@@@@@@.@@..@@.@@@@.@.@@@@@@@@@@@.@@@.@@@@@@@...@@.@@@@.@@.@.@@@@@@.@@.@......@@@..@.@.@@@@.@@@@@....@.@@....@@@..@@@.@@@.
|
||||||
|
@.@@@.@.@@@@.@.@@@..@@...@@...@@.@@@@@.@.@@@.@.@.@.@@@.@@.@@@@@@@@@.@.@@@.@@@@@@...@@.@@..@@@@@@...@@@@@@@@.@@@@.@@..@.@.@.@@...@..@@.@.@@..
|
||||||
|
.@@.@@@.@.@.@.@@@@@.@@@.@.@@@@@@@@@.@@@...@@.@@..@@@@.@.@@@@@@.@@@@@@@@@..@.@.@.@.@@@@@@@.@@..@..@@.@@@...@.@.@..@@@.@....@@@@@@..@..@@@@@@.
|
||||||
|
@.@....@@@@@@.@@@@@@@@@@..@@@.@.@@@@@@@@@@@.@@@@.@@.@@.@.@@@.@@@.@@.@@....@@.@@.@@..@@.@@.....@.@.@.@.@@..@@.@@@.@@@..@@@@.@.@@@@@@@@@.@@...
|
||||||
|
.@@.@@@@@@@@@@..@@@@..@.@@@..@@@..@.@.@..@..@@@@.@@.@.@@.@@@@@@..@..@@@@@.@@.@@.@@@@...@@.@.@.@@..@.@..@@@@..@@@@@@.@@@@@@@.@@@@@@@@@.@...@.
|
||||||
|
...@@..@@.@@@@@.@@@@@@.@@@@@@@@@.@.@@@@@@.@.@@.@@@@@@@..@@@@@..@@.@@...@@@..@@.@@@...@.@@@...@.@@@@@..@@@@.@.@.@@@@@.@.@@@@..@@@.@.@.@@@@@.@
|
||||||
|
@@.@@@@.@@...@@.@@....@@.@.@@@@...@@@@.@@@@@@.@@@@..@..@@@@@...@.@@@@.@.@@..@@@.@@.@@@..@@@.@..@@@...@@@@.@..@.@.@.@@@.@@@@@@.@@@.@.@..@..@.
|
||||||
|
@@@@@@.@.@..@.@@@@@@@.@@@.@@@.@@@@..@@...@@@..@..@@@@@@@.@@.@.@@@@...@@@.@.@@@@@.@@.@..@@@@@@@.@.@...@.@.@...@@..@@@.@@@@@@@@.@@..@@.@.@.@@.
|
||||||
|
@@.@@.@@@@@@@.@.@@.@@@@@@@@@@@.@.@...@@@@@@@@.@.@.@@@.@@@.@@.@.@.@@...@@.@@..@.@@@@@@..@@@.@@.@@@@@..@.@..@.@@@@.@@@@@.@.@.@..@@.@..@@@@.@@@
|
||||||
|
@@@@.@@@.@.@@@.@....@@@@@.@@.@.@.@@@.@@.@@@@@@.@@.@@.@@@@@@@@@@.@@..@.@@@@.@@@@...@....@@.@@@@@@..@@@.@@.@@.@...@@.@.@.@@@.@@@@..@@...@@.@@@
|
||||||
|
@..@@.@@@.@...@@@@@.@.@@..@@@@@@.@.@@.@@@@@@@.@@@..@.@@.@..@.@@@@@@.@.@@@@..@.@@.@@@..@@.@@@@......@@.@@.@.@.@.@.@@@.@@@..@.@@@@@@@..@..@@@@
|
||||||
|
@.@..@@@.@@@@@...@@.@@..@@@@@.@@..@.@.@@@.@.@@@..@@.@..@@@.@@...@@@@.@@@@.@@@...@..@...@.@@@.@@.@.@@.@@@.@.@@..@@@..@@@@.@.@@..@@@.@@@@@@.@@
|
||||||
|
@@@@.@@@@@@@..@@@@.@@@...@.@.@@...@@..@@..@@@@@..@.@@@@.@@@.@@@@.@.@@.@.@..@@..@.@@.@...@.@..@.@.@@@.@@.@@@@.@@@@..@...@....@.@@.@@@@@.@@@@@
|
||||||
|
.@@..@@@@@@.@@@@@@@.@@@@...@@@@.@@@@@@@.@.@..@@.@@.@@@@...@...@.@@..@.@@..@@@@@..@@.@@.@..@.@.@...@@@..@..@@@@@..@@@.@@@...@..@.....@.@@@.@.
|
||||||
|
@@@..@.@@@.@.@@@@@@@@.@@@@.@@@.@.@@@@@@@.@..@@....@..@@@...@..@@@.@@@@..@@@..@..@@..@@..@.@..@@.@.@..@@@..@.@.@@.@.@@@@@@@@@@@@.@@@.@@.@@.@.
|
||||||
|
@@@.@@...@.@@@@.@.@@@@@@@@@@.@@@@.@@@@@.@@@.@.@.@..@.@@@@.@@.@@..@@...@.@...@@@..@@@..@@@..@.@.@.@.@@..@@@.......@.@.@..@..@.@@@@@...@@@..@.
|
||||||
|
@@@@@@@.@@@@@.@@@@@@@@..@@.@..@@@@..@..@@@...@...@..@@@@@@@@@@@@@@@..@.@.@.@@@.@.@@....@@.@@@@@@.@.@.@..@@@.@@@@@@@..@.@..@.@@@.@@@.@@.@@.@.
|
||||||
|
....@@@...@@.@@@@@.@@@@.@@@@...@..@@...@@..@.@@@.@@@@.@@@@...@....@..@@.@.@.@@.@..@@@@.@@@@.@@.@.@....@@@@.@.@@@@@.@@@@.@@@@.@@@@...@.....@@
|
||||||
|
@@.@@...@@.@@@@@.@@@@.@@@@@@@@.@...@@@.@@@@@@@@@@@@..@@@@@....@@@@@@.@@..@..@@@@@.@@.@...@@@@.@.@.@.@@..@@@@@.@@@@.@@.@@.@@@@@@@@@.@@..@.@@.
|
||||||
|
@.@@.@@@@@@@@...@@@.@@.@@.@...@@@@..@@...@@@@@@@.@..@.@@.@@@@@@@...@.@.@@@@.@@.@.@.@.@@.@@..@@@....@.@@@@@@@@@@@..@@@@@@@.@@@@..@...@@.@@@.@
|
||||||
|
..@@@@@@..@@@@.@@@.@@@@@.@@@@@@@.@.@@@.@@@@@@@@@@@@@@@@@@..@@.@@@@@@.@@@@@@.@@.@@@@...@@..@.@@.@.@@@@.@..@@@@@@.@@@@..@.@.@..@@@@.@@@@@@..@@
|
||||||
|
.@@..@@@@@....@@@@..@@@@.@@@@@@.@.@@..@@@@@@..@...@..@@@.@@..@@..@@.@@@.@@.@.@.@@.@@.@@@.@..@@@@@@.@.@.@@....@@@@@...@@@@..@@@@.@@@@...@@..@
|
||||||
|
@@@@@@@@.@@@@@@.@@@@@.@@@@..@@@@.@@@..@@@@@.@@...@@.@@.@@.@.@@@@@@@@@@@@@.@@@@.@@..@@@@@.@.@@....@..@..@.@@..@@@@@@..@@.@@@@@.@.@@@@.@@.@.@@
|
||||||
|
@@.@@...@..@@@@.@.@@@@@.@@@..@@@@..@.@@.@.@@.@@@@@.@@@@@.@@..@@@@.@@@.@..@@...@@@@@@.@@@@@..@@@@@@@@.@.@@@@@.@@@@.@@.@....@@.@@@.@..@@..@@@.
|
||||||
|
@@@@.@@..@@.@@..@..@.@.@@.@....@@..@.@.....@@..@@@@.@..@@..@.@@@@@.@..@..@@@@.@@.@.@.@@@@@@@@@.@@.@@@@@@.@....@@@..@@.@@@.@@@@.@@@@@@@.@@@.@
|
||||||
|
.@...@.@@.@..@@.@.@@@.@.@.@...@.@@@@.@@@@@..@@@.@.@....@@@@@@@@@@@@.@@@@@@@@@@@@.@...@@.@..@@@@....@.@.@@@.@@.@@@.@..@@@@@@@.@.@@@@.@@.@@@..
|
||||||
|
@@@@@.@.@@@@@@@.@.@.@.@.@.@@@..@@....@.@@.@@@@.@.@@.@.@@.@@@@@.@....@@@@@@@@@@@..@@@@.@.@@..@@.@.@.@@@@@@@@..@@@@.@.@@@@.@@@..@@@@@.@@@@@@@@
|
||||||
|
@....@@.@.@@@.@@@.@@@@@..@....@@@@@.@..@.@@..@@.@@@@@.@@.@.@@@@@@.@@@@.@@@.@.@.@@@@@....@@@.@@.@@.@@@..@.@....@.@.@@.@.@@.@.@@...@@@.@.@@.@.
|
||||||
|
....@@@@@@@.@@@.@@@.@.@@@.@@...@@@@@......@@@.@@.@@@.@.@@@@@@@.@@@.@..@@@@@.@.@...@@@...@.@@@.@..@@.@@..@..@.@@@..@@.@@@.@@.@@.@@.@@@@@..@@@
|
||||||
|
@@@@@@@..@@@...@@.@@.@@@.@@@@@.@@.@@@...@.@.@@@...@@@..@@@.@@@@@@..@@.@@@.@..@@.@@@.@@@..@@@.@@@@@@.@@@@@@.@@.@...@@..@.@..@@...@.@..@.@@@@@
|
||||||
|
@@.@@@.@.@@.@@@@@@....@@.@@@@@@@@.@@..@@@@@.@@@.@.@..@..@.@@@..@@@@.@@.@@@@@@.@..@@.@@@.@@.@@.@@@@.@@@@@@...@@.@@@@@@.@@.@@@...@@@@@@..@@.@@
|
||||||
|
.@@@@.@@.@@@.@@@@@..@.@.@.@@.@@@@..@@@@@@@@@@@@@.@@....@..@@@@..@@@@@..@@.@@@@@.@@@@..@@@.@.@.@@@@..@@@@@@@@.@@.@...@..@@@@@.@..@.......@@@@
|
||||||
|
@@@@@@@@.@@@@@@@@.@@@@@.@@.@@@@@.@@@@.@@@@.....@.@....@@..@...@@@@@..@@@@.@@@@.@.@@@@@.@@.@@@@@.@..@@@@.@.@.@@@@.@@.@@@.@..@.@@@@@@@.@@@@@.@
|
||||||
|
@@@...@@.@@..@.@@@@@@@@@@@@@@@..@@@@@@.@..@@@..@@@@@@@..@@@.@.@@@.@.@.@@...@@..@..@.@.@@@.@@@@@..@.@@.@@.@@..@.@@@@..@@.@...@.@@.....@...@.@
|
||||||
|
.@.@..@@.@.@.@.@@@.@@@@..@@.@@.@.@@.@@@..@@.@.@@@.@@@@@..@@@@@@@.@@@@@..@@..@@@..@....@.@@.@@@@@@@@@..@.@@...@.@@.@.@.@@@@@@@@.@@@@@..@@@@@.
|
||||||
|
@@@@..@.@.@@@..@@@.@.@..@@@@.@@@..@.@@..@@...@.@..@@..@.@@@@@@@@.@..@@@@@@@@@.@.@@.@@@@@....@..@@@@@@@@@@@@@@@@@...@..@@..@@...@.@@@@@@.@@@.
|
||||||
|
@@@@@...@@@.@@@.@..@@@@@@@@@@..@@.@.@@@@.@.@@@@@@@.....@@@@@@.@....@..@@..@@.@@@@.@.@@..@@@..@@@@.@@@.@..@@..@.@@.@.@..@..@@@@@@.@@@@@@@@.@@
|
||||||
|
.@.@.@@..@@@.@@@.@.@@@@..@..@@@@@@@.@@@@@@@@@..@..@.@@@@.@@.@.@@@@.@@@.@..@@@@@..@.@@@@@@@@@@.@@..@.@@@@@@.@@@@@..@..@..@...@@.@@@@@@.@..@.@
|
||||||
|
@@@.@@@@@@@@.@@..@@..@...@@@..@.@@.@@@@@@.@@@@....@..@@@.@..@@.@..@@@.@.@@@@@@@@@.@@@@..@.@..@.@@.....@@@@...@@.@@@...@@@.@.@@@.@@.@...@@..@
|
||||||
|
@..@@@@.@.@@@@@.@.@@.@.@@@@.@.@@.@....@.@@.@..@@.@@@@.@@@.@...@@..@@@@@@@@.@.@@@@..@@.@....@.@@.@.@@@@@..@...@@.@@@.@@.@..@.@@...@@@.@@@@.@@
|
||||||
|
@@@@..@@.@.@@@...@..@@.@@.@@@@@.@@@.@.@@.@@@@...@..@@..@@.@...@@@@.@.@@@@@@@@.@.@@@@.@@@.@@.@@..@@@.@@@@.@@.@@.@@@@.@@@..@@.@@@@@.@@@@@.@@@.
|
||||||
|
.@@..@.@@@@..@@.@...@@@....@.@@..@@@..@@@@@.@@..@@@@@@.@@@@.@@@.@@...@...@@.@.@@@@@@@@@@@.@@.@@@@@.@@@.@...@.@@@@@@.@@..@..@..@@@@@.@.@@@@.@
|
||||||
|
@@@@@@.@..@..@@..@..@..@@@@..@.@@@.@@..@@..@.@@@@@@@@..@@..@...@@.....@@@@@@@.@@@@..@..@.@@@...@@@@.@@@@@@.@..@.@@@.@@@@@@@..@..@@.@@@@@@.@.
|
||||||
|
@@@@@@@@@@@@@..@@@.@@@.@@..@..@@@@@@@..@@@@@@...@..@@..@@@@.@@...@.@..@@@@..@@..@....@@..@@...@.@@.@..@@@@.....@.@@@@...@@@.@@@@@@@.@@.@@@@@
|
||||||
|
...@.@.@@.@.@@@.@@@@.@..@@.@.@@@......@.@@.@.@@@.@.@..@@@.@@@.@@@...@@.@@.@@@@@@.@....@..@@@.@@@@@..@@@@@..@.@.@@..@...@@.@@@@@@@.@@..@@..@@
|
||||||
|
..@@..@@@@@@@@@@.@@@@@@@.@.@@.@@@@@@@.@.....@.@@@@@@@@@..@.@@..@.@@@@@@@@.@@@@..@@@.@@@@@...@@..@@@.@@@@@@@@@...@@@.@.@@@@@@@@..@@@@...@@@..
|
||||||
|
.@@@@@@....@@@@@.@@@@.@@.@.@@@.@@.@@@@@@.@...@@@@.@@@@..@@.@@..@@@@.@@...@@..@@@.@.@@.@.@@@@@@@@..@.@@@...@@.@@.@..@@@@..@@@@.@@.@@@@..@@@..
|
||||||
|
@@@.@@.@@@@@@.@@@@@.@@.@@.@..@@@.@@@..@@@....@.@.@..@@..@@@@@..@@@@@@@@.@..@@@.@@.@@@@@@@.@@@@@@@.@.@@...@.@.@@@@@.@@@@@@..@@@.@.@.@@@..@@@@
|
||||||
|
@@@@@@..@@@@@@@.@@.@@@@@@@@@.@@@.@@@.@@.@.@..@..@@..@@@@@@.@@@.......@@.@@.@.@.@..@.@@@@.@@@.@@....@@.@@.@@@@@@@@@@@@@@@@@@@@@.@@..@@@...@@@
|
||||||
|
@@@@.@@@@.@@@@@@@@@.@...@@@@.@@@@@@.@.@@@..@@@@@@@@...@@...@.@.@@.@@@@@@@@.@@@..@@@.@@.@@..@.@@@.@.@@.@@...@@@..@@.@@@.@.@@.@.@@@@.@@@@@..@@
|
||||||
|
@.@@@@@@.@@@.@@.@..@..@@@..@@@@.@..@@.@@...@@..@@@@@..@@@@@@@..@@..@@.@..@@.@.@.@@..@...@@@@@@@@@@..@@@@.@.@@@.@...@@.@@.@@@@.@@..@.@.@@@.@@
|
||||||
|
@@@.@@.@@@@.@..@@@.@@@@.@@@@@@@@@@@@@@@@.@@.@@@@...@@@.@@@@.@...@@.@@@@@.@@....@@.@.@@@@...@@@.......@@..@@.@.@@.@@@@....@.@@@@@@@..@..@@@.@
|
||||||
|
.@@.@@@..@@@.@@@@@@@..@@.@@@.@.@..@@@.@@@.@@@@@.@..@@.@@@@.@@@@@..@@@.@.@@@.@.@@@@@@@@.@@@@..@..@@@.@..@.@.@@.@.@@@.@@@@..@.@..@@.@@@.@..@@@
|
||||||
|
@....@@@@@@...@@@@@@..@@@@@@@.@@.@...@@.@@.@.@..@..@@@@@@@.@..@@@..@..@@....@@@@..@.@@..@.@@.@@.@...@@@..@@@.@.@.@.@.@@@..@.@@@@.@@.@.@..@@.
|
||||||
119
day4/main.go
Normal file
119
day4/main.go
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/kelindar/bitmap"
|
||||||
|
)
|
||||||
|
|
||||||
|
func readLines(filename string) []string {
|
||||||
|
raw, err := os.ReadFile(filename)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return strings.Split(string(raw), "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
type warehouse struct {
|
||||||
|
boxes *bitmap.Bitmap
|
||||||
|
width uint32
|
||||||
|
height uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildWarehouse(lines []string) warehouse {
|
||||||
|
wh := warehouse{
|
||||||
|
boxes: &bitmap.Bitmap{},
|
||||||
|
}
|
||||||
|
wh.height = uint32(len(lines))
|
||||||
|
if wh.height == 0 {
|
||||||
|
return wh
|
||||||
|
}
|
||||||
|
wh.width = uint32(len(lines[0]))
|
||||||
|
if wh.width == 0 {
|
||||||
|
return wh
|
||||||
|
}
|
||||||
|
for y, line := range lines {
|
||||||
|
for x, char := range line {
|
||||||
|
if char == '@' {
|
||||||
|
set(wh.boxes, wh.width, wh.height, uint32(x), uint32(y))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wh
|
||||||
|
}
|
||||||
|
|
||||||
|
func set(area *bitmap.Bitmap, width uint32, height uint32, x uint32, y uint32) {
|
||||||
|
if x >= width || y >= height {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
area.Set(y*width + x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func debug(area *bitmap.Bitmap, width uint32) {
|
||||||
|
area.Range(func(offset uint32) {
|
||||||
|
fmt.Printf("(%d, %d)\n", offset%width, offset/width)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildNeighbors(width uint32, height uint32, offset uint32) *bitmap.Bitmap {
|
||||||
|
y := offset / width
|
||||||
|
x := offset % width
|
||||||
|
var neighbors bitmap.Bitmap
|
||||||
|
set(&neighbors, width, height, x+1, y)
|
||||||
|
set(&neighbors, width, height, x-1, y)
|
||||||
|
set(&neighbors, width, height, x+1, y+1)
|
||||||
|
set(&neighbors, width, height, x-1, y+1)
|
||||||
|
set(&neighbors, width, height, x+1, y-1)
|
||||||
|
set(&neighbors, width, height, x-1, y-1)
|
||||||
|
set(&neighbors, width, height, x, y+1)
|
||||||
|
set(&neighbors, width, height, x, y-1)
|
||||||
|
return &neighbors
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wh warehouse) countAccessibleBoxes() uint32 {
|
||||||
|
boxes := wh.boxes.Clone(nil)
|
||||||
|
boxes.Filter(func(offset uint32) bool {
|
||||||
|
neighbors := buildNeighbors(wh.width, wh.height, offset)
|
||||||
|
neighbors.And(*wh.boxes)
|
||||||
|
accessible := neighbors.Count() < 4
|
||||||
|
return accessible
|
||||||
|
})
|
||||||
|
return uint32(boxes.Count())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wh *warehouse) removeAccessibleBoxes() uint32 {
|
||||||
|
boxes := wh.boxes.Clone(nil)
|
||||||
|
removed := uint32(0)
|
||||||
|
boxes.Filter(func(offset uint32) bool {
|
||||||
|
neighbors := buildNeighbors(wh.width, wh.height, offset)
|
||||||
|
neighbors.And(*wh.boxes)
|
||||||
|
accessible := neighbors.Count() < 4
|
||||||
|
if accessible {
|
||||||
|
removed++
|
||||||
|
}
|
||||||
|
return !accessible
|
||||||
|
})
|
||||||
|
wh.boxes = &boxes
|
||||||
|
return removed
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
filename := "input0.txt"
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
filename = os.Args[1]
|
||||||
|
}
|
||||||
|
lines := readLines(filename)
|
||||||
|
wh := buildWarehouse(lines)
|
||||||
|
fmt.Printf("%v\n", wh.countAccessibleBoxes())
|
||||||
|
total := uint32(0)
|
||||||
|
for {
|
||||||
|
count := wh.removeAccessibleBoxes()
|
||||||
|
if count == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
total += count
|
||||||
|
}
|
||||||
|
fmt.Printf("%v\n", total)
|
||||||
|
}
|
||||||
12
day5/input0.txt
Normal file
12
day5/input0.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
3-5
|
||||||
|
10-14
|
||||||
|
16-20
|
||||||
|
19-19
|
||||||
|
12-18
|
||||||
|
|
||||||
|
1
|
||||||
|
5
|
||||||
|
8
|
||||||
|
11
|
||||||
|
17
|
||||||
|
32
|
||||||
1180
day5/input1.txt
Normal file
1180
day5/input1.txt
Normal file
File diff suppressed because it is too large
Load diff
125
day5/main.go
Normal file
125
day5/main.go
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
filename := "input0.txt"
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
filename = os.Args[1]
|
||||||
|
}
|
||||||
|
lines := readLines(filename)
|
||||||
|
kitchen := parseKitchen(lines)
|
||||||
|
fmt.Printf("%d\n", kitchen.countFreshIngredients())
|
||||||
|
fmt.Printf("%d\n", kitchen.countEverythingFresh())
|
||||||
|
}
|
||||||
|
|
||||||
|
func readLines(filename string) []string {
|
||||||
|
raw, err := os.ReadFile(filename)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return strings.Split(string(raw), "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
type container struct {
|
||||||
|
start uint64
|
||||||
|
stop uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i container) contains(id uint64) bool {
|
||||||
|
return i.start <= id && i.stop >= id
|
||||||
|
}
|
||||||
|
|
||||||
|
type kitchen struct {
|
||||||
|
coolers []container
|
||||||
|
ingredients []uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k kitchen) countFreshIngredients() uint64 {
|
||||||
|
total := uint64(0)
|
||||||
|
INGREDIENTS:
|
||||||
|
for _, ingredient := range k.ingredients {
|
||||||
|
for _, cooler := range k.coolers {
|
||||||
|
if cooler.contains(ingredient) {
|
||||||
|
total++
|
||||||
|
continue INGREDIENTS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseKitchen(lines []string) kitchen {
|
||||||
|
k := kitchen{
|
||||||
|
coolers: []container{},
|
||||||
|
ingredients: []uint64{},
|
||||||
|
}
|
||||||
|
coolers := true
|
||||||
|
for _, line := range lines {
|
||||||
|
if line == "" {
|
||||||
|
coolers = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if coolers {
|
||||||
|
parts := strings.Split(line, "-")
|
||||||
|
cooler := container{}
|
||||||
|
cooler.start, _ = strconv.ParseUint(parts[0], 10, 64)
|
||||||
|
cooler.stop, _ = strconv.ParseUint(parts[1], 10, 64)
|
||||||
|
k.coolers = append(k.coolers, cooler)
|
||||||
|
} else {
|
||||||
|
id, _ := strconv.ParseUint(line, 10, 64)
|
||||||
|
k.ingredients = append(k.ingredients, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return k
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k kitchen) countEverythingFresh() uint64 {
|
||||||
|
type pivot struct {
|
||||||
|
id uint64
|
||||||
|
start bool
|
||||||
|
}
|
||||||
|
pivots := []pivot{}
|
||||||
|
for _, cooler := range k.coolers {
|
||||||
|
pivots = append(pivots,
|
||||||
|
pivot{id: cooler.start, start: true},
|
||||||
|
pivot{id: cooler.stop, start: false},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
sort.Slice(pivots, func(i, j int) bool {
|
||||||
|
pi, pj := pivots[i], pivots[j]
|
||||||
|
if pi.id < pj.id {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if pi.id > pj.id {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !pi.start && pj.start {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
total := uint64(0)
|
||||||
|
insideStarted := uint64(0)
|
||||||
|
within := uint16(0)
|
||||||
|
for _, pivot := range pivots {
|
||||||
|
if pivot.start {
|
||||||
|
if within == 0 {
|
||||||
|
insideStarted = pivot.id
|
||||||
|
}
|
||||||
|
within++
|
||||||
|
} else {
|
||||||
|
within--
|
||||||
|
if within == 0 {
|
||||||
|
total += 1 + pivot.id - insideStarted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
}
|
||||||
7
go.mod
7
go.mod
|
|
@ -1,3 +1,10 @@
|
||||||
module ballstads.name/aoc2025
|
module ballstads.name/aoc2025
|
||||||
|
|
||||||
go 1.25.5
|
go 1.25.5
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/kelindar/bitmap v1.5.3 // indirect
|
||||||
|
github.com/kelindar/simd v1.1.2 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e // indirect
|
||||||
|
)
|
||||||
|
|
|
||||||
8
go.sum
Normal file
8
go.sum
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
github.com/kelindar/bitmap v1.5.3 h1:/ty1SvbLE5ZKO4ToFNeXe3P3RrQsoj4a0x5gZNp5Vzo=
|
||||||
|
github.com/kelindar/bitmap v1.5.3/go.mod h1:j3qZjxH9s4OtvsnFTP2bmPkjqil9Y2xQlxPYHexasEA=
|
||||||
|
github.com/kelindar/simd v1.1.2 h1:KduKb+M9cMY2HIH8S/cdJyD+5n5EGgq+Aeeleos55To=
|
||||||
|
github.com/kelindar/simd v1.1.2/go.mod h1:inq4DFudC7W8L5fhxoeZflLRNpWSs0GNx6MlWFvuvr0=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
|
||||||
|
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e h1:CsOuNlbOuf0mzxJIefr6Q4uAUetRUwZE4qt7VfzP+xo=
|
||||||
|
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
Loading…
Add table
Add a link
Reference in a new issue