2024 day 6
This commit is contained in:
parent
45653f84c7
commit
829f92b899
3 changed files with 155 additions and 0 deletions
15
2024/day06/day06.bqn
Normal file
15
2024/day06/day06.bqn
Normal file
|
@ -0,0 +1,15 @@
|
|||
in←>•FLines"input"
|
||||
map←'#'=in
|
||||
i‿j←⊑¨/¨(∨´˘⋈∨˝)'^'=in
|
||||
|
||||
Move←{𝕊map‿i‿j‿v:
|
||||
p←⌽/i↑j⊏˘map
|
||||
newi←{0<≠p ? 1+⊑p ; ¯1}
|
||||
v↩1¨⌾((∾⟜j¨1+newi+↕i-newi)⊸⊑)v
|
||||
⟨⌽∘⍉map,(≠map)-j+1,newi,⌽∘⍉v⟩
|
||||
}
|
||||
•Show +´⥊3⊑Move•_while_(0≤2⊸⊑)⟨map,i,j,(≢map)⥊0⟩
|
||||
|
||||
candidates←≢⟜i‿j¨⊸/⥊↕≢map
|
||||
Stop←{𝕊map‿i‿j‿v: ((i‿j⊑v)∧(¬⟨i-1,j⟩⊑v)∨(¬⟨i+1,j⟩⊑v))∨j<0}
|
||||
•Show +´{0≤2⊑Move•_while_(¬Stop)⟨1⌾(𝕩⊸⊑)map,i,j,(≢map)⥊0⟩}¨candidates
|
130
2024/day06/input
Normal file
130
2024/day06/input
Normal file
|
@ -0,0 +1,130 @@
|
|||
...#........................................#........#.................#............#.#.......................#...............#..#
|
||||
...#........#.....#..................................................................................#......#..#..................
|
||||
.................#.......................#.#........#......#...........................................#...#..........#...........
|
||||
..................#..................#...#.....................................#........#.........................................
|
||||
...#.....#.......#..............#.#....##.............#....##......................................#...................#..........
|
||||
...#..........................................................................................................................#...
|
||||
..#..#.............#.....#...............#.......#..............................................#....#............................
|
||||
......................#..#...............#...................#....#..........................#...#............#...#....##.........
|
||||
..#.#.........#................#............#............#.#.......#................#....#..#.....................................
|
||||
.......................................................................#.....................................#...........#........
|
||||
...........#.....................................................................#.................................#......#.......
|
||||
...#.........#....................................................#..............#.............#..........#.......................
|
||||
.................................................................................................#................................
|
||||
..................................#.#.#...#.......#.............#.......................#..#.......................#.#............
|
||||
.......................#.........................................#..........#...#.....#....................................#......
|
||||
.......#.......#.#...........#......................#.....#..#...#.#...............#.............................#...#............
|
||||
............##...#......#.........#......#............................................................#.........#..............#..
|
||||
..#........................................#........##..#...............................................................#.........
|
||||
...........#..............##................................................................................#.....................
|
||||
..#................................................................................#..............#...............................
|
||||
...................................##..............#..........................#.......#..#...............#........#...............
|
||||
....#............#.........................#................................................................#........#............
|
||||
............#.....................................................................#.............................................#.
|
||||
............#..........#.......#...........#.#......#..............#.........#.......................................#......#.....
|
||||
..#...............................................#..................................#.............................#.............#
|
||||
.........................................................................#........#................#......#.......#....#........#.
|
||||
.......................................................................#.....##.................................................#.
|
||||
..............#.............#...........................#...#..#....................................................#.............
|
||||
.......#..........................#.......................###..................................#.....................#..#.........
|
||||
................#.................#.............#......................................................................#........#.
|
||||
.#.....#................#......................................................................#................#.................
|
||||
................................#........................#........#..#........................#...................................
|
||||
..............................................................................................#.....................#.........#...
|
||||
..................#.................#.........................#.....#................#............................................
|
||||
......#...................#...#...................#..................#...........................#......###...................#...
|
||||
.............................##.....#..............#..............................................................#....#..........
|
||||
......#..................#....................................................###....................#..............#.............
|
||||
............#...#..................#........#.............#..............................#.........#..........................#...
|
||||
....#...............................#......#......#...............#.#......#............#...................................#.....
|
||||
.......#...................................#.#.#.........................................................#..................#.....
|
||||
.....................#.......#.#......#.#.....................#...................................................................
|
||||
......#.....#............................................................................#............#.......#..#................
|
||||
..........#.#......#...................................#....#.#............##.....................................................
|
||||
...............#........................#..................................#...........#...................................#......
|
||||
.#....................................................#.......................................................................#...
|
||||
......#.........................................#...#.........................................#........#..........................
|
||||
.........................................#..........#.............................................................................
|
||||
...................#.....................................#.....................#..#............#....#........................##...
|
||||
.................................#.........#.............#.............................#...........................#...#..........
|
||||
..#................................................................#.....#....#.................................#.................
|
||||
........#................#............#.#..........................................#..............................................
|
||||
..#...........##.....................#..#..........................#...#...#....#.................................................
|
||||
................................................................................#.................................................
|
||||
............#...........#.........#....#.........................................................................#................
|
||||
.............................#...........................................#...............##...................................#...
|
||||
......................#..............#...#........................#........................................#......................
|
||||
............#..............#...#.....#.....#..........#...........................#........#...............#......................
|
||||
..................#............................#....#................................................................#............
|
||||
..#........................#.............................#......#...............#....#...........#................................
|
||||
.................................................#................................................#..................#........#...
|
||||
.#......#.........................................................#...........#...#.......................#.......................
|
||||
..........................................#.......##........#................................................#..##............##..
|
||||
..............#...#....................................................................#........#...........................#.....
|
||||
................#....................................................................#........................................###.
|
||||
....#............................................#........................#.................#........#.....#...#.....#.#....#.....
|
||||
...##..........#..................................................................................................................
|
||||
#....#.........#....................#.#.........................#..........##.......#....#..#....................#................
|
||||
........#.........#..........#.................#..................#................................#.......#................#...#.
|
||||
.#..........................................#..#..#......#................................#.#.#..#................................
|
||||
....#.......#.........#............................................................#....#.........................................
|
||||
.....................................................................#...#......................#.................................
|
||||
............#.....#.....#..........#...............................................................................#..............
|
||||
.........................#...#.#.......#....................................................................#.................#...
|
||||
......................................................#.#..........................#...#................#.........................
|
||||
.....#.........#.........#..............................................................#...................#.#......#............
|
||||
.......................................#......#.......................#.................................................#.....#...
|
||||
.....#....#.......................................................................................................................
|
||||
#..........#....#....................................#.............#...............#...................#..........#...............
|
||||
..#....................................##.....................................#...............................#...................
|
||||
....#..................................#........................#.................................................................
|
||||
....#................................................................................................#...................#........
|
||||
....#................................................................................#............................................
|
||||
..........#.....#...................#.......................#......#..............................................................
|
||||
#...................#..........#............................................................#............#..............#.........
|
||||
...#...#....#................................#............................#.##.....................................#..............
|
||||
..........#.........#.....#...........#............................#...............#.#....#................#....................##
|
||||
.....#...................................................#........................................................................
|
||||
............##....................................#..................#.#..#.....................#.........#....##......#...#......
|
||||
...........#.......#....................#.......................#..#.................#.......#.........#..........................
|
||||
#.....................#..#..............................................................................................#.........
|
||||
....#....#..............#............##....................................................^.................#..............#.....
|
||||
.........#......................................................#..............#............#...#......#....#.....................
|
||||
.......##...................#...........#.........#.......................................#..........................#............
|
||||
.#........#.#........................#...........#............#..#........#........#.............#................................
|
||||
..................##........##.................................................................................#................#.
|
||||
...#...................#.....#...........#.........#..#............#..................................#.....#.....................
|
||||
.................#.........#..........#............#......#.........................#.............#.......#......................#
|
||||
.................................................................#...............#.....#.#....#...................................
|
||||
..........................#...........................................................................................#..#........
|
||||
..............#.................................................................................##......................#.........
|
||||
....#...#....................#...............................................#................#............#......................
|
||||
........................................................................#........#................................................
|
||||
....#.....#......................#.......#............#......................................#..................................#.
|
||||
................#................................#.#.............#.#.........#..............................................#.....
|
||||
..............#..................#...#...........................................................................#................
|
||||
...#..........#....................................................#...............................#...........#.......#..........
|
||||
...................................#....................#..#.#........#..#.......................#...#.....#......................
|
||||
.......#.....#.#.......#....#............#...............#..........#.................#........#.#................................
|
||||
.....#....#.........#........#.......#............................................................................................
|
||||
..#........#......#............................................................#..........#...............................#.......
|
||||
..#..#...................................#....................#...#.#................#......................#.....................
|
||||
....................................#......#.....................#...........#.....................#........#.....................
|
||||
.#..................#.........................................................................................................#...
|
||||
..............#...........#.#....#..#......#..#.#...#.#.........................................................................#.
|
||||
...#............##.......................................................#.......................#..#.............................
|
||||
......#........#..........#..#.#........#.....................#...................................................................
|
||||
...#...........#.........................................#............#.............#....#.....................................#..
|
||||
...........#.....................#......................................................................................#.........
|
||||
.......#..............#...............#............#..........................#............................#........##............
|
||||
.............#..........#..............................................#................#..............................#..........
|
||||
...............#..............................#.................#.....#................#....#.....................................
|
||||
............#.................#..........#........#............#..#......#.......................#....#...#.#...#.#...............
|
||||
.......#.#...................................##..............#.....#.....................#.................................##.....
|
||||
..#..#...#...#....#.............#..#.....................................................................................#........
|
||||
......#......................#...#...#..........#......................................#.................#....#.................#.
|
||||
.......#...........#...........#...................#..............................#.......................................#.......
|
||||
......#.......................................#...............................................#.........#........#....#.........##
|
||||
......#.................................................................#...#............#..........#.............................
|
||||
.....................................#..........#.........#.....#.............#...........#.......................................
|
||||
.#.....................................#......................#.....#..#..........................................................
|
10
2024/day06/test
Normal file
10
2024/day06/test
Normal file
|
@ -0,0 +1,10 @@
|
|||
....#.....
|
||||
.........#
|
||||
..........
|
||||
..#.......
|
||||
.......#..
|
||||
..........
|
||||
.#..^.....
|
||||
........#.
|
||||
#.........
|
||||
......#...
|
Loading…
Add table
Add a link
Reference in a new issue