Skip to content

Instantly share code, notes, and snippets.

@codesections
Created December 11, 2019 03:23
Show Gist options
  • Save codesections/e6b3b28cbb439c60a823807f0b1faaf8 to your computer and use it in GitHub Desktop.
Save codesections/e6b3b28cbb439c60a823807f0b1faaf8 to your computer and use it in GitHub Desktop.
Advent of Code day 10
in⎕nget '10.input' 1 p'#'=in
can_see{:0
0=+/¯1{p[[0];[1]]}¨ els_btwn }
els_btwn{ :
n+( slope_btwn )
(n),(n ) }
slope_btwn{{÷(/)}--}
visible_pts{ cur
+/{(cur can_see ) p}¨,{.,}21}
pt1/,(21 21 (visible_pts¨,{.,}21))p
⎕div1
target11 11 shape21 21
els((shape[0]).,(shape[1]))
anglesshape {(180÷(1))ׯ3(÷/target slope_btwn )}¨,els
quad{ r(-1)1 1 0 0 b(-1)0 1 1 0
rfn(-1)'' '' '' '' bfn(-1)'' '' '' ''
(target[1]+r)(rfn)[1](target[0]+b)(bfn) }
zapped
zap{ line(-1)(0,target[1]) (target[0],shape[1]-1) ((shape[0]-1),target[1]) (target[0],0)
zapped,{ 0<+/p[]:1p[]/
}(target els_btwn line)
zapped,{({(target can_see )(p)}¨)/}(, quad els)[, quad angles] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment