Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
17
2022/day09/day09.bqn
Normal file
17
2022/day09/day09.bqn
Normal file
|
@ -0,0 +1,17 @@
|
|||
⟨ToNats,Split⟩←•Import"../bqn-libs/strings.bqn"
|
||||
Dirs←{𝕩≡'R' ? 1‿0; 𝕩≡'U' ? 0‿1; 𝕩≡'L' ? ¯1‿0; 𝕩≡'D' ? 0‿¯1}
|
||||
d‿n←<˘⍉>' '⊸Split¨•FLines⊑•args
|
||||
inp←(⊑¨ToNats¨n)/Dirs¨∾´d
|
||||
|
||||
Dist←⌈´∘|-
|
||||
Follow←{𝕩+(2≤𝕩 Dist 𝕨)×(××⌈∘|)2÷˜𝕨-𝕩}
|
||||
Move←{Follow`𝕩⊸+⌾⊑𝕨}
|
||||
|
||||
F←{
|
||||
pos←(<𝕨⥊<⟨0,0⟩)Move`𝕩
|
||||
inds←⍷>¯1⊸⊏¨pos
|
||||
# Disp←{⊑⟜".#"¨(⍉⌽˘(1⊸+⌾(𝕩⊸⊑))𝕨⥊0)}
|
||||
# •Show (1+(⌈´-⌊´)inds) Disp inds
|
||||
≠inds
|
||||
}
|
||||
•Show 2‿10 F¨ <inp
|
2000
2022/day09/input
Normal file
2000
2022/day09/input
Normal file
File diff suppressed because it is too large
Load diff
8
2022/day09/test1
Normal file
8
2022/day09/test1
Normal file
|
@ -0,0 +1,8 @@
|
|||
R 4
|
||||
U 4
|
||||
L 3
|
||||
D 1
|
||||
R 4
|
||||
D 1
|
||||
L 5
|
||||
R 2
|
8
2022/day09/test2
Normal file
8
2022/day09/test2
Normal file
|
@ -0,0 +1,8 @@
|
|||
R 5
|
||||
U 8
|
||||
L 8
|
||||
D 3
|
||||
R 17
|
||||
D 10
|
||||
L 25
|
||||
U 20
|
Loading…
Add table
Add a link
Reference in a new issue