Advertisement
musifter

AoC 2024, day 1, part 2 (dc)

Dec 1st, 2024 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.35 KB | Source Code | 0 0
  1. # Command: dc -fdc-p2.dc <input
  2.  
  3. 0 Sa                # bottom sentinel of stack a
  4.  
  5. # Read Input
  6. ?
  7. [
  8.     # stack: item2  item1
  9.     d;b 1+ r:b      # b(item2)++
  10.     Sa              # push item1 on stack a
  11.     ? z0<I
  12. ] dsIx
  13.  
  14. # Process
  15. 0La                   # sum
  16. [
  17.     d;b *+          # sum += b(item) * item
  18.     La d0<L
  19. ] dsLx
  20.  
  21. [Part 2: ]nrp
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement