Advertisement
musifter

AoC 2023, day 8 part 1 (dc)

Dec 8th, 2023 (edited)
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | Source Code | 0 0
  1. ?
  2. z dsn                       # i = #dirs (store in n)
  3. [
  4.     1-                      # i--
  5.     d3R r:d                 # dirs(i) = top (L=4C | R=52)
  6.     z1<L
  7. ] dsLx
  8.  
  9. # Make hash number from top-characters
  10. [
  11.     0r                      # stack: ... top acc i
  12.     [
  13.         r256* 3R+           # ... next i acc*100+top
  14.         r1- d0<I            # i--
  15.     ] dsIx
  16.     +                       # clear i (+0)
  17. ] sN
  18.  
  19. # stack: 0
  20. ??
  21. [
  22.     6lNx _4R 3lNx :h        # hash(label) = (right:left)
  23.     ? z1<L
  24. ] dsLx
  25.  
  26. [r] sr
  27.  
  28. # stack: 0
  29. 16i
  30. 414141                      # steps=0 label=AAA
  31. [
  32.     rd ln%;d                # label steps (L|R)
  33.     3R;h                    # steps (L|R) hash(label)
  34.     10 6^~                  # steps (L|R) right left
  35.     3R 4C=rs.               # rot if L, scrap top; steps label=(left|right)
  36.     r1+                     # steps++
  37.     r d5A5A5A!=M            # quit at ZZZ
  38. ] dsMx
  39.  
  40. [Part 1: ]nrp
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement