|
@@ -49,31 +49,23 @@ func parts(rotations []Rotation) (int, int) {
|
|
|
dial := 50
|
|
dial := 50
|
|
|
|
|
|
|
|
for _, rotation := range rotations {
|
|
for _, rotation := range rotations {
|
|
|
|
|
+ changed := rotation.Clicks / 100
|
|
|
|
|
+ left := rotation.Clicks % 100
|
|
|
|
|
+
|
|
|
if rotation.Direction == 'L' {
|
|
if rotation.Direction == 'L' {
|
|
|
- dial -= rotation.Clicks
|
|
|
|
|
|
|
+ dial -= left
|
|
|
} else {
|
|
} else {
|
|
|
- dial += rotation.Clicks
|
|
|
|
|
|
|
+ dial += left
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if dial > 100 {
|
|
if dial > 100 {
|
|
|
- passedZeros += dial / 100
|
|
|
|
|
- if dial%100 == 0 {
|
|
|
|
|
- passedZeros--
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ passedZeros++
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if dial < 0 {
|
|
if dial < 0 {
|
|
|
- if abs(dial) > 100 {
|
|
|
|
|
- passedZeros += abs(dial) / 100
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if rotation.Clicks != abs(dial) {
|
|
if rotation.Clicks != abs(dial) {
|
|
|
passedZeros++
|
|
passedZeros++
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if dial%100 == 0 {
|
|
|
|
|
- passedZeros--
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
dial %= 100
|
|
dial %= 100
|
|
@@ -82,8 +74,14 @@ func parts(rotations []Rotation) (int, int) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if dial == 0 {
|
|
if dial == 0 {
|
|
|
|
|
+ if changed > 0 {
|
|
|
|
|
+ changed -= 1
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
zeros++
|
|
zeros++
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ passedZeros += changed
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return zeros, passedZeros
|
|
return zeros, passedZeros
|