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] ]
- " Changes to booleans to give basic integer coercion: "
- Boolean extend [ generality [^1] ]
- True extend [ truncated [^1] ]
- False extend [ truncated [^0] ]
- "
- | Mainline
- "
- locks := Set new.
- keys := Set new.
- ((stdin contents tokenize: '\n\n') collect: #lines) do: [:item |
- " Convert images to bitArrays, AND them and any overlap will be a 1: "
- bitArray := item join inject: 0 into: [:a :b | a * 2 + (b = $#)].
- ((item first first = $#) ifTrue: [locks] ifFalse: [keys]) add: bitArray.
- ].
- part1 := locks inject: 0 into: [:sum :l | sum + (keys count: [:k | (k bitAnd: l) = 0])].
- ('Part 1: %1' % {part1}) displayNl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement