Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
12
2023/day03/day03.bqn
Normal file
12
2023/day03/day03.bqn
Normal file
|
@ -0,0 +1,12 @@
|
|||
digits←'0'+↕10
|
||||
n‿m←≢input←>•FLines"input"
|
||||
|
||||
sympos←⍉>m(⌊∘÷˜⋈|)/⥊¬input∊digits∾'.'
|
||||
digpos←(0≠≠)¨⊸/ <˘¨{+`1⊸<|+´˘+`⁼𝕩}⊸⊔ ⍉>m(⌊∘÷˜⋈|)/⥊input∊digits
|
||||
near←{∨´⥊1⊸=⌈´¨|¨(<˘sympos)-⌜𝕩}¨digpos
|
||||
nums←•ParseFloat¨⊑⟜input¨digpos
|
||||
•Show +´near/nums
|
||||
|
||||
gearpos←<˘⍉>m(⌊∘÷˜⋈|)/⥊input='*'
|
||||
nearnums←{(1=⌈´¨⌊´¨|¨¨𝕩⊸-¨¨digpos)/nums}¨gearpos
|
||||
•Show +´×´¨(2=≠)¨⊸/nearnums
|
Loading…
Add table
Add a link
Reference in a new issue