Advertisement
musifter

AoC 2023, day 1 (dc part 1)

Dec 1st, 2023 (edited)
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | Source Code | 0 0
  1. [ +d ] sF # first = ord (+0)
  2. [ s. z3<L q ] sN # junk char, loop if more input
  3.  
  4. 0 # sum
  5. ?
  6. [
  7. 0d # sum ... char2 char1 last first
  8. [
  9. 3R 48- # char1 -> ASCII ordinal - 48
  10.  
  11. # d 1>N # next if <1 (ASSUME: no ASCII chars < '1')
  12. d 9<N # next if >9
  13.  
  14. r d0=F # last ord first
  15. 3Rs. # last = ord (by junking old)
  16.  
  17. z3<L
  18. ] dsLx
  19.  
  20. rA*++ # sum += 10 * last + first (because string reversed)
  21. ? z1<M
  22. ] dsMx
  23.  
  24. [Part 1: ]np
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement