Advertisement
musifter

AoC 2024, day 22, part 1 (dc)

Dec 22nd, 2024 (edited)
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.82 KB | Source Code | 0 0
  1. # Command: dc -fdc-p1.dc <input
  2.  
  3. # 24-bit XOR top two on stack
  4. [
  5.     0d                  # (i=bit#) result
  6.     [
  7.         3R4R            # arg2 arg1 i result
  8.         2~ 3R 2~        # bit1 rest1 bit2 rest2
  9.         3R -d*          # bit (a-b)^2: sum rest1 rest2 i result
  10.         4R d 2r^ 3R*    # (bit<<i) i rest1 rest2 result
  11.         5R+             # (result+=bit) i rest1 rest2
  12.         r1+ d 24>L      # i++, loop until i == 3
  13.     ] dsLx 3R4R++s,     # 3 result junk2 junk1
  14. ] s^
  15.  
  16. ?
  17. [
  18.     [num: ]np
  19.     2000                    # i num
  20.     [
  21.         r                   # num i
  22.         d 64* l^x           # num = (64*num) ^ num
  23.         d 32/ l^x           # num = (num/32) ^ num
  24.         d 2048* l^x         # num = (2048*num) ^ num
  25.  
  26.         r1- d0<I
  27.     ] dsIx +
  28.  
  29.     lp+sp
  30.  
  31.     ? z0<M
  32. ] dsMx
  33.  
  34. [Part 1: ]n lpp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement