musifter

AoC 2025 day 7 (dc)

Dec 7th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | Source Code | 0 0
  1. # Command: perl -pe'print pos()." "while(m/[S^]/g);$_="\n"' <input | grep -v '^$' | dc -fdc-p12.dc
  2.  
  3. # Process Beam: beam -> 0 (num is passed in reg n)
  4. [
  5.     lp1+sp              # part1++
  6.     d1+ d;t ln+ r:t     # table(beam+1) += num; beam
  7.     d1- d;t ln+ r:t     # table(beam-1) += num; beam
  8.     0 r:t               # table(beam) = 0
  9.     0
  10. ] sB
  11.  
  12. ? 1r:t                  # table(start)=1
  13. ?
  14. [
  15.     # split1 split2 ...
  16.     [
  17.         d;t dsn         # table(split) split ...
  18.         0<B
  19.         s.
  20.         z0<L
  21.     ] dsLx
  22.  
  23.     ? z0<M
  24. ] dsMx
  25.  
  26. [Part 1: ]n lpp
  27.  
  28. # Sum table for part 2
  29. 0*
  30. F0                      # i sum
  31. [
  32.     d;t                 # table(i) i sum
  33.     3R+ r               # i sum+=table(i)
  34.     1- d0<L
  35. ] dsLx +
  36.  
  37. [Part 2: ]n p
Advertisement
Add Comment
Please, Sign In to add comment