Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/gst -q
- "
- | Mainline
- "
- area := 0.
- pos := (0 @ 0).
- trench := 0.
- stdin linesDo: [ :line |
- parts := line subStrings.
- delta := parts second asNumber.
- vert := (parts first = 'U') | (parts first = 'D').
- (parts first = 'U') | (parts first = 'L') ifTrue: [ delta := delta * -1 ].
- 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.
- ].
- part1 := (area abs + trench) / 2 + 1.
- ('Part 1: %1' % {part1}) displayNl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement