Advertisement
Guest User

AoC day 1, part 1 (dc)

a guest
Dec 1st, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. [q] SX # exit if we run out of stack without an answer
  2.  
  3. [
  4. d 2020 r - * pq # print top * (2020 - top) and exit
  5. ] SP
  6.  
  7. [
  8. z 0 =X # exit if stack empty
  9.  
  10. d 1 r:v # put 1 at v[top]
  11. d 2020 r - ;v 1 =P # dup, if v[2020 - top] = 1 then call Print
  12.  
  13. s. # junk top of stack to remove unneeded dup
  14. lLx # loop
  15. ] SL
  16.  
  17. lLx
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement