Advertisement
musifter

AoC 2015, dc (part 1)

Nov 17th, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | Source Code | 0 0
  1. # Vowels
  2. # Bit table: 000001000001000001000100010 (2130466)
  3. [ 2r^ 2130466r/ 2% lv+ sv ]sV # vowels += vowel_table lookup bit
  4.  
  5. # Bad strings
  6. # Bit table: 110111111101111111111110101 (117374965)
  7. [ d2r^ 117374965r/ 2% lb* sb ] sB # bad *= bad_table lookup bit
  8.  
  9. # Doubles
  10. [ 1sd ] sD # mark double flag
  11.  
  12. [ 1+ ] sS # score string
  13.  
  14. 0 # count = 0
  15. ?
  16. [
  17. 0dsdsv 1sb # init flags
  18.  
  19. # Process string (note: arrives backwards)
  20. [
  21. dlVx # vowel check
  22.  
  23. rd3R- # c1 -> difference (c1-c2)
  24. d0=D # check doubles
  25. _1=B # check bad strings
  26.  
  27. z 2<L # leave: last-char count
  28. ] dsLx
  29.  
  30. lVxlv # check last-char for vowel
  31. lb ld ** 3!>S # num vowels * bad (0|1) * doubles (1|0)
  32.  
  33. ? z 1<M
  34. ] dsMx
  35.  
  36. p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement