Advertisement
musifter

AoC 2021 day 5, part 2 (dc)

Dec 5th, 2021
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. [q] SX
  2.  
  3. [1+] S1 # inc
  4. [_1*] SN # negate
  5. [ d 0>N ] S| # abs
  6. [ d l|x d 0=1 / ] SS # sign
  7.  
  8. [ lc 1+ sc ] SC
  9.  
  10. [
  11. lp dd;g 1+ d 2=C r:g # p -> (g(p)+1 = 2, count) g(p)+1 p p -> (g(p) = g(p)+1) p
  12. le=X # p -> (p = e, exit)
  13. lp ls+ sp # p -> (p = p+s)
  14. lIx
  15. ] SI
  16.  
  17. [
  18. z 0 =X # stop when stack empty
  19. sy sx sb sa # store top four in (x,y) and (a,b)
  20.  
  21. ly 1000* lx+ sp # calculate pos
  22. lb 1000* la+ se # calculate end
  23. lb ly- lSx 1000* la lx- lSx+ ss # calculate step
  24. lIx
  25.  
  26. [count = ]n lcps.
  27.  
  28. lLx
  29. ] SL
  30.  
  31. 0 sc # count = 0
  32. lLx
  33.  
  34. [Part 2: ]n lcps.
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement