Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/gst -q
- Symbol extend [ value: arg [^arg perform: self] ]
- Collection extend [ at: idx inc: val [^self at: idx put: ((self at: idx) + val)] ]
- "
- | Mainline
- "
- sections := (stdin contents tokenize: '\n\n') collect: #lines.
- order := Set from: (sections first).
- parts := Dictionary from: {true -> 0. false -> 0}.
- sections second do: [:list |
- sorted := (list subStrings: ',') sort: [:a :b | order includes: (a,'|',b)].
- parts at: (list = (sorted join: ','))
- inc: (sorted at: sorted size // 2 + 1) asNumber.
- ].
- ('Part 1: %1' % {parts at: true}) displayNl.
- ('Part 2: %1' % {parts at: false}) displayNl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement