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 ]
- value: arg1 value: arg2 [ ^arg1 perform: self with: arg2 ]
- ]
- Collection extend [ sum [^self inject: 0 into: [:a :b | a + b]] ]
- "
- | Mainline
- "
- input := (stdin contents tokenize: '\n\n') collect: #lines.
- sizes := input allButLast collect: [:p | (p collect: [:row | row count: [:chr | chr == $#]]) sum].
- part1 := input last count: [:region |
- | nums |
- nums := (region substrings: 'x: ') collect: #asNumber.
- area := nums first * nums second.
- needArea := ((nums allButFirst: 2) with: sizes collect: #*) sum.
- tileSpots := (nums first // 3) * (nums second // 3).
- needSpots := (nums allButFirst: 2) sum.
- (area >= needArea) and: [tileSpots >= needSpots]
- ].
- ('Part 1: %1' % {part1}) displayNl.
Advertisement
Add Comment
Please, Sign In to add comment