Advertisement
musifter

AoC 2021 day 6 (dc)

Dec 6th, 2021
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. [q] SX
  2.  
  3. [
  4. z 0 =X # stop when stack empty
  5. d;g 1+ r:g # g(top) = g(top) + 1
  6. lLx # loop
  7. ] SL
  8. lLx
  9.  
  10. [
  11. 1- d _1=X # i = i-1 -> (i == _1 exit) i
  12. d lt+;g ls+ ss # i -> (s = s + g(t+i)) i
  13. lSx
  14. ] SS
  15.  
  16. [
  17. 0 ss 9lSx s.
  18. [Part 1: ]n lsps.
  19. ] S1
  20.  
  21. [
  22. lt d 80=1 d 256=X
  23. d;g r7+ ;g+ lt7+:g # t -> g(t) t -> g(t+7)+g(t) -> g(t+7) = g(t+7)+g(t)
  24. lt d;g r9+ ;g+ lt9+:g # ditto, but with t+9
  25. lt 1+ st # t++
  26. lTx
  27. ] ST
  28. 0 st lTx
  29.  
  30. 0 ss 9lSx
  31. [Part 2: ]n lsps.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement