Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/gst -q
- String extend [ asRadix: rad [^Number readFrom: (ReadStream on: self) radix: rad] ]
- "
- | Mainline
- "
- area := 0.
- pos := (0 @ 0).
- trench := 0.
- stdin linesDo: [ :line |
- parts := line subStrings.
- delta := (parts third atAll: (3 to: 7)) asRadix: 16.
- dir := (parts third at: 8) digitValue.
- vert := (dir \\ 2) = 1. " U and D "
- (dir >= 2) ifTrue: [ delta := delta * -1 ]. " U and L "
- vert ifTrue: [ pos y: (pos y + delta) ]
- ifFalse: [ pos x: (pos x + delta) ].
- area := area + (delta * (vert ifTrue: [pos x] ifFalse: [-1 * pos y])).
- trench := trench + delta abs.
- ].
- part2 := (area abs + trench) / 2 + 1.
- ('Part 2: %1' % {part2}) displayNl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement