Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
21
2023/day21/day21.bqn
Normal file
21
2023/day21/day21.bqn
Normal file
|
@ -0,0 +1,21 @@
|
|||
m‿n←≢input←>•FLines"input"
|
||||
s←m(⌊∘÷˜∾|)/⥊input='S'
|
||||
grid←1˙⌾(s⊸⊑)input='.'
|
||||
dirs←∾⟜-⋈⟜⌽↕2
|
||||
|
||||
•Show ≠{⍷(⊑⟜grid¨)⊸/⥊𝕩+⌜dirs}⍟64⟨s⟩
|
||||
|
||||
≠ps←{(m‿n⊸|⊑grid˙)¨⊸/⍷⥊𝕩+⌜dirs}⍟((⌊m÷2)+m×↕3)⟨s⟩
|
||||
|
||||
# Lagrange polynomial interpolation, arbitrary nodes and values
|
||||
Lagrange←{x𝕊y:
|
||||
d←≠x
|
||||
w←÷×˝1˙¨⌾((∾˜¨↕d)⊸⊑)-⌜˜x
|
||||
{+´y×w××´¨𝕩⊸-¨/⟜x¨¬⌽⌽⟜(d↑1)¨1+↕d}
|
||||
}
|
||||
f←(↕≠ps) Lagrange ≠¨ps
|
||||
•Show F (26501365-65)÷m
|
||||
|
||||
# Lagrange polynomial interpolation with nodes at 0‿1‿2 and values at 𝕩
|
||||
LagrangeCoeffs←{⌽+˝[[1,-3,2],[1,-2,0],[1,-1,0]]×[0.5,¯1,0.5]×𝕩}
|
||||
•Show (LagrangeCoeffs ≠¨ps)(+´×⟜(⋆⟜↕⟜3))(26501365-65)÷m
|
131
2023/day21/input
Normal file
131
2023/day21/input
Normal file
|
@ -0,0 +1,131 @@
|
|||
...................................................................................................................................
|
||||
...............#.....#...#......#...............#.....#...#...........#..#....##.#..#.........#..............#...........#..#......
|
||||
........#.#..........#.##..#.......#.#.#.......#..#........................#............#...#....#.............#....#.........#....
|
||||
.....#......#...................#...#......#.............#..............#.#....#.......#...#...#......##.#.#...........#..###......
|
||||
.........#............#...##.........#.#....#........#..........................#....#.#......#......#....#....#............#.#....
|
||||
...#.....#................#.#..........#..........#.#.#...........#.......#..............#......#.......##.....#.........##.#......
|
||||
..........#....................#............#........#............#............#....#..........#.........................#.........
|
||||
...#.#...................#.#......##..#........#.##.....................................#........##............#.##....#...........
|
||||
.........................................#...#.......................#...........................#..#........#....##.#...##........
|
||||
...#.......#...#.......#..#.#.......#.......#........................#........#....#....#...#.#.....#...#...........#........##.#..
|
||||
..#....#.............#........................#..##.............................#..#.................#....##.......#.......#....#..
|
||||
.........................#.......#...#...........#..................#..............#.#....#.....#...#........#...........#......#..
|
||||
............#..................#...#.......#...#.#.........#.......................#............#.......#....#.....#..........#....
|
||||
..........#........#......##.#.....#...#................#....##...........#................#.......#........#......#...#....#..#...
|
||||
.................#.......................##...............#.....#.....#............#.................#..........#......#.....#.....
|
||||
.....#.###................#..........#...................#.##........#...............#....#...............#..#................#.#..
|
||||
.#..#..........#..................#...................................#......#.................#.#..................#..............
|
||||
..........#..#...#.#...........#.#..#....................#....................#..........#.#.#.....#....#...........#........#.....
|
||||
.#.............#.......##.##.........#.#..............#.......#.............#.........................................#....#.#.....
|
||||
.............#.....#.#........#..........#..............#.....................#..................#..#........#.#.....#...#.........
|
||||
....#.......#..............#.....#.......#...........#.............#.##..................#.................#..#......#.#...#....#..
|
||||
..#....#.....#......................#.....................#..........#..##........#.........#.............#......#.................
|
||||
...##.......#.......#...#..##..................#.........##....................#.#...................................#..#..........
|
||||
........#.........#..##........................#......#........#...#...#........#......................................#.......#...
|
||||
....#..#....#.#.#.................#.............#.........#.............#....#................#..#.....#...##.....#.........##.....
|
||||
...................#................#...............................#.................#...........#.....##.#.......................
|
||||
.....#........#........#........................#..............#.............................................#........#...#........
|
||||
.......#............#.................................#.......#........#...#..............................#.....#.#.#......#.#.#...
|
||||
.....................###....#.#................#.#....#........##.#..#.......#...#............................#..........###....#..
|
||||
.#.....##.#......#.#........#.#..............#...............#.........#.........#.....#...........#.............................#.
|
||||
...#.....#...........#.#......#................#..#....#...#..#......#................#....#.............#.#....#..................
|
||||
..#....##......#.............#...............#.................................#.......#................#...........#.#............
|
||||
..........#....#....##.......................#.#.#..................#.....#..............#................#..................#.....
|
||||
.....#......................................#....#......................#..........#........#........................#.............
|
||||
..#.#..#........#...#..#...................#............#..#...#......#.#...#............#.....#...............#..............#....
|
||||
..#....#..##..........#...........#......................##................#...#...............................#..#....#........#..
|
||||
......#........#...................#.#.......#..#.#....#..##...#.........##......#....#..........#....................#....#.......
|
||||
.#.##.....#.....#..................#.....#..#..#....#....#......#...........#......#....#.........#........##..#.#..##.............
|
||||
........#..#.....#.....#.......#.#......................#..................#.#.......##...................................#..#.....
|
||||
..#........#.........................#.......#..............................#.....##.........#..#.##...............................
|
||||
..............................#....................#......................#.....#..#.............................#..........#......
|
||||
........#.#.....................#......#.....#.............##...............#....#.#...#..........................#...#....#.......
|
||||
........#...................#.#.##.##........................#.#........................#...............................#..#...#.#.
|
||||
.............##.................#......#.#.##.......#.........................#.......................#.................#..........
|
||||
..##.....#..........................##..........#....#.............................##.....###......#...........................#...
|
||||
...#.......#...#..............#................#.#.....#..#..................#..#...##....#....#.......#...........#.........#.....
|
||||
.....#.......#.........#..#.......##.............#.##...#.......#................#..........#............#.................#.......
|
||||
..............#..........##....................#......#...##..................................#.#.......#.#..............#.........
|
||||
..#.....#..#.#.............#................#......................#.#.................##.......###.#....#..............##.........
|
||||
....................#.........#...#............#.#......#..........#........#..........................#..#.#............##........
|
||||
.......#...#..........#.........#........#....#......###.......#..#.........##....#..............#.......#..#..........#...........
|
||||
.....##.#.................................#.....#.............#.#.......#..##.............#........................................
|
||||
.......#..................##.##..#............#......#...#....##........##.#................#....#..#..##..........................
|
||||
..##.#..............###..#........#...#...#.........#.....................#....#.......##............#...#..................#......
|
||||
....#..............#...........#.....##................##...##.......#...#....#...#............#..#..............................#.
|
||||
.........................#.........#..................##................#....#...#...........#......#..#....####.............#.....
|
||||
.....................#...#....#........#...........#..........#....................#..#..#..........#..............................
|
||||
.#..................#..................#........#............#.#..............#....#...............#........#....##............##..
|
||||
...............#....#.#.........#...#.......#...#.......#.......#................#.##................#.................#...........
|
||||
..............#.#.......#...#....#......#.............#...................##...#.......##......##..................................
|
||||
..........##.#..#.......##........#.##......#............#.#..##...............#...#.....#...#............#......#.................
|
||||
........#.#.#........................................##....#..#...............#.......##......#......#...........#..##.............
|
||||
......................................#........................#.........#.....#...................#...............................
|
||||
.........................#....#.......#...................#..#..#.#.....#..................#......##.......................#.......
|
||||
......#....#.......#.............#.........................#........#.#...#.....#..#....#......#....#.#.......#...........#........
|
||||
.................................................................S.................................................................
|
||||
...........#...#.....#......................#.......#.............#.#............#.##.#...#........#.......#........#.......##.....
|
||||
................#..#........#...#.....................#...............#...........................##.....#.........#...............
|
||||
.............##.##.#...#........#..#...#....................#...#.......................#............#.............................
|
||||
................#....#.#.#...#...............#...........#..............................##........................#................
|
||||
.......................................#.....#...........#.........#...................#..#..#.................#.........#.......#.
|
||||
..#...............#....#.#.#............................#.#..#............#.........#......#........#....#......................#..
|
||||
...#......................#....#.#....................##..........#......#...#........#....#.....................#.#...........#.#.
|
||||
...............#...#.................................##...#.#.......#...#...........#...................#...........#..............
|
||||
................#......#.............#.#...##...##......#......#..#..........#..#......#...........................................
|
||||
..................#.#.....#.##.....#....#..........................##.#.#....#.........#...#.....#........#...##.#...............#.
|
||||
........................#...#..............#....#.......#......#......#......#..#...............##.............##..................
|
||||
..#...##.............#..................#....#.......................#..........#...##......................#..#..#..........#...#.
|
||||
....##.#..........#...#..........#.......#...#............#.#.........#..#...#.#.......##......#..###..#.........#.................
|
||||
.........#.............#...#..........#........#..##..................#..#.........................#.....#...#..............#......
|
||||
.......#...#.............#.#....###................#...#.................#.#.............#..................##...............#.....
|
||||
....#....##..............#......#.....#.....#...#..#............#...##.......#.#....#...#........##.#..#...............#...#.......
|
||||
.#..#....#............#.........#...........#......#...#............#...........#......##....#........#..........................#.
|
||||
....###...#.................#.......#............#.#.........#...................#.##............#....................#............
|
||||
........#...............................#..........#................#......#....#.............#..........##..........#.....#..##...
|
||||
....#.....###...................##..##.##...#..##...##...#....#.......#..................#........#..#...................#.........
|
||||
..#.#............#................#...#.#.......#.........#.....#.#.....#.............#.....#..#.....................#..##.........
|
||||
............#.#..#....................#.....#..........#.#...................#....................#..#.......................#..#..
|
||||
....#....#.....#..................##................#..#...#.......##...............#.....##..#................#..##..##...#.......
|
||||
..................#..............................##................#....#....#........................................#...#...##...
|
||||
.............##........................#....#........##......#.............#.#...#................#..........#..#.#.....#.......#..
|
||||
....#.#..#...#..#..................#..#..#..#.#......#..#..#.#.....####......#...........##.#....#..#..............#............#..
|
||||
.#...#.................................#............##...#....................#.#..#....#.......#................#..#..........#...
|
||||
..#.................#.................#...................#.#.......#....#...............#......#.#...............#................
|
||||
......###.....#.........#.................#.#.............#..#..#.......#.....#.............................#....##..##..#.........
|
||||
..........###....#.#.#....#........#............###..#.........#....#...........#.......#......#........#......#....#............#.
|
||||
.....##...#.#.##....................##...#.#..#......#.......#......#...#........#.....................#.......#......#.....##.....
|
||||
.#.....#..#...............................#....#.................................##...................#.......#...............#....
|
||||
.....................##.....#...................#......................#.#..#................................##....................
|
||||
....#....#..........#........#.........#...##..........#.....#..#..#.............#..##....................................#........
|
||||
..........#.#.............#.................#............#.....#......#...............................#.................#....#.#...
|
||||
......#...#.#.....#.#.##..#.#............###....#.....#................##......#.......#..#....................#.....#.............
|
||||
.....#....#....................#.....................#..........#.....#.............#..#.......................#.#.................
|
||||
......#....#...............................#...#........#.......................#....................##...#..#......#...##....#....
|
||||
....#..............#...........#................#.#......#........##...#..#....###..................#.........#.............#......
|
||||
......#....#....#.....#..##.#.#.............##.......#.......#....#...##..........................#....###...#...#.............#...
|
||||
.#....##......#........#.#..........#..........................................#................#..................#...............
|
||||
..#......#...#....#.......##.....#.....................#.....#.#..#...#...#......#.......................................#..#......
|
||||
......#..............#.......#.#..........................#.............#.......#.#.............#......#....................#..#...
|
||||
..#...#.........................#.#....#............................#.....................#.....#.................#................
|
||||
...................##......#.....#.............................#......##....#............#...#......................#..............
|
||||
......#...#..#.##.............#........#..#.........##...#....#......#..#......#..........#...........#..........#.#..#.#..........
|
||||
.#..#..#.........#.......#.......#.........#..........##...##...#.#...#........................................#....#..............
|
||||
.#..#.#.#....#......#................#........................#.#.....#........................#...#......................#......#.
|
||||
...............##...............##....................#..#.#.........................#.......#.......#...........#............#....
|
||||
..........#.........#.#.............#....#..#.#.............##....#......#.#.........................#..#.....#.......#........#...
|
||||
....##......#...#.............................#...............#......#................#.....................................#......
|
||||
....###.#..#.......#...................#....#..........................#..#..................#.....#....#.....#................#.#.
|
||||
............#.#..#.#.###........##..#.##...........................#.................#.#.............#.............#.....##........
|
||||
..#......#................................#.#.....................#......................#........#.....#.....#.#...#.....#........
|
||||
.............#..........#.#.##......#..#....................##................................#..............#......#...........##.
|
||||
.....#...#..............#..#....#..#..............................#..........................#.###..............#...##.....##......
|
||||
.#...#..#.......#.#...............#....#.....#..#....#..............#...................................................#.#.#......
|
||||
.......##.........#.#....#...........#.....#....#...............#....................#..................##......#........#.........
|
||||
...#.#.....#....#.................#..#................#........#..................#......#............#....#...........#..#........
|
||||
.....#...#..................#.......#.........#...#....#...................#...##..#.#....#....#.##..#..##.##..................#...
|
||||
.....................#..#...#.....#............#..........................#.##.....................#..#...#......##.....#.....#....
|
||||
..#........#.......##.#..............#..##................................#..#.#....#.....#...............#.................#.#....
|
||||
...#.................................#.........#...........................#....##.#...................#......##.................#.
|
||||
.........#..........#.#......#....##....#.#...#.........#................................#....#..#..............#....##...#........
|
||||
...................................................................................................................................
|
11
2023/day21/test
Normal file
11
2023/day21/test
Normal file
|
@ -0,0 +1,11 @@
|
|||
...........
|
||||
.....###.#.
|
||||
.###.##..#.
|
||||
..#.#...#..
|
||||
....#.#....
|
||||
.##..S####.
|
||||
.##..#...#.
|
||||
.......##..
|
||||
.##.#.####.
|
||||
.##..##.##.
|
||||
...........
|
Loading…
Add table
Add a link
Reference in a new issue