Skip to content

Commit cab4b01

Browse files
committed
day 2 part 2
1 parent a9d2749 commit cab4b01

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

02/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ func main() {
3939
}
4040

4141
func getPosFromCommands(vals []command) (horizontalPos int, depth int) {
42+
aim := 0
4243
for _, c := range vals {
4344
switch c.bearing {
4445
case "forward":
4546
horizontalPos += c.distance
47+
depth += aim * c.distance
4648
case "down":
47-
depth += c.distance
49+
aim += c.distance
4850
case "up":
49-
depth -= c.distance
51+
aim -= c.distance
5052
default:
5153
fmt.Println("what da fuk", c.bearing)
5254
}

0 commit comments

Comments
 (0)