Advertisement
musifter

AoC 2024 day 13 (dc)

Dec 13th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.86 KB | Source Code | 0 0
  1. # Command: tr -c '[0-9]' ' ' </tmp/input | dc -e'?0' -fdc-p12.dc
  2. # Replace the ?0' with '?10000000000000' for part 2.
  3.  
  4. so                  # Store offset in o
  5.  
  6. # Score: div -> junk
  7. [
  8.     d               # div div
  9.     lar/ 3*         # 3*a/div div
  10.     r lbr/+         # b/div+3*a/div
  11.     ls+ss
  12.     0
  13. ] sS
  14.  
  15. [
  16.     # stack frame: (Ty Tx by bx ay ax)
  17.     lo+sy lo+sx     # store Ty Tx
  18.  
  19.     d lx*           # Tx*by by bx ay ax
  20.     3Rd ly*         # Ty*bx by Tx*by bx ay ax
  21.     3Rr- sa         # a = Tx*by-Ty*bx; stack: bx by ay ax
  22.  
  23.     3Rd lx*         # Tx*ay ay bx by ax
  24.     5Rd ly*         # Ty*ax ax Tx*ay ay bx by
  25.     3R-  sb         # b = Ty*ax-Tx*ay; stack: ax ay bx by
  26.  
  27.     4R*_3R*-        # div=ax*by-ay*bx
  28.     dd              # div div div
  29.     lar%            # a%div div div
  30.     r lbr% +        # b%div+a%div div
  31.     0=S s.
  32.     z0<M
  33. ] dsMx
  34.  
  35. lsp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement