~pmikkelsen/aoc2023

53c4a0b881ef3344aff563aa1b526f497442161c — Peter Mikkelsen 7 months ago 09910a8
Solve day 6
2 files changed, 13 insertions(+), 0 deletions(-)

A Day6.aplf
A input/day6
A Day6.aplf => Day6.aplf +11 -0
@@ 0,0 1,11 @@
 (r1 r2)←Day6;input;count;solve
 input←↑{⍎9↓⍵}¨⊃⎕NGET'input/day6' 1
 solve←{
     (times dists)←↓⍵
     (a b c)←¯1 times(¯1×dists+1)
     d←(b*2)-⊃×⌿4 a c
     (low high)←((-b)(+,⍥⊂-)d*0.5)÷2×a
     ×⌿1+(⌊high)-⌈low
 }
 r1←solve input
 r2←solve⍪⍎¨,/⍕¨input

A input/day6 => input/day6 +2 -0
@@ 0,0 1,2 @@
Time:        44     82     69     81
Distance:   202   1076   1138   1458