Advertisement
musifter

AoC 2022, day 1 (Gnu smalltalk)

Dec 1st, 2022
2,600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Smalltalk 0.39 KB | Source Code | 0 0
  1. #!/usr/local/bin/gst -q
  2.  
  3. Collection extend [
  4.     apply: method  [ ^self collect: [:x | x perform: method] ]
  5.     sum            [ ^self inject: 0 into: [:a :b | a + b] ]
  6. ]
  7.  
  8. elves := stdin contents tokenize: '\n\n'.
  9. elf_cal := (elves collect: [:x | (x substrings apply: #asNumber) sum]) sorted.
  10.  
  11. ('Part 1: %1' % {elf_cal last}) displayNl.
  12. ('Part 2: %1' % {(elf_cal last: 3) sum}) displayNl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement