advent-of-code/2019/day04/day04.dyalog
2024-11-12 21:46:18 +01:00

14 lines
No EOL
511 B
APL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

⎕io0
a b245182 790572
p(,(.,))/6/10
x{(1)-¯1}¨p
n10¨((/¨0=x)/¨0x)/p
((n>a)n<b)/n ⍝ part 1
n210¨(({/2=}¨()¨p)/¨0x)/p
((n2>a)n2<b)/n2 ⍝ part 2
⍝ better version (inspired from
⍝ https://github.com/jayfoad/aoc2019apl/blob/master/p4.dyalog)
p10¯1a+1+b-a
+/({/2/}{/2=/})p ⍝ part 1
+/({/2/}{/¨2=()¨})p ⍝ part 2