Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
29
2023/day15/day15.bqn
Normal file
29
2023/day15/day15.bqn
Normal file
|
@ -0,0 +1,29 @@
|
|||
⟨Split⟩←•Import"../bqn-libs/strings.bqn"
|
||||
≠input←","Split⊑•FLines"input"
|
||||
|
||||
H←(⊑⌽)0(256|17×+)`-⟜@
|
||||
|
||||
•Show +´H¨input
|
||||
|
||||
Parse←{
|
||||
⊑'='∊𝕩 ? •ParseFloat⌾(1⊸⊑)'='Split𝕩 ;
|
||||
⊑'-'∊𝕩 ? 1↑'-'Split𝕩
|
||||
}
|
||||
|
||||
Replace←{t‿n𝕊𝕩:
|
||||
⊑(<t)∊⊑¨𝕩 ? i←⊑/((<t)≡¨⊑¨)𝕩 ⋄ t‿n˙⌾(i⊸⊑)𝕩 ;
|
||||
𝕩∾⟨𝕨⟩
|
||||
}
|
||||
|
||||
Run←{
|
||||
boxes←256⥊⟨⟨⟩⟩
|
||||
Step←{
|
||||
𝕊⟨t⟩: boxes (((<t)≢¨⊑¨)⊸/)⌾((H t)⊸⊑)↩ ;
|
||||
𝕊t‿n: boxes (t‿n⊸Replace)⌾((H t)⊸⊑)↩
|
||||
}
|
||||
Step¨𝕩
|
||||
boxes
|
||||
}
|
||||
|
||||
Pow←+´(1+(↕≠))⊸×
|
||||
•Show Pow Pow¨ 1⊸⊑¨¨ Run Parse¨ input
|
Loading…
Add table
Add a link
Reference in a new issue