55 lines
775 B
Go
55 lines
775 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
if bytes, err := os.ReadFile("input"); err != nil {
|
|
panic(err)
|
|
} else {
|
|
content := strings.TrimSpace(string(bytes))
|
|
|
|
turns := strings.SplitSeq(content, "\n")
|
|
|
|
position := 50
|
|
zeroCount := 0
|
|
|
|
zeroPasses := 0
|
|
|
|
for turn := range turns {
|
|
left := turn[0] == 'L'
|
|
|
|
if steps, err := strconv.Atoi(strings.TrimSpace(turn[1:])); err != nil {
|
|
panic(err)
|
|
} else {
|
|
for range steps {
|
|
if left {
|
|
position--
|
|
} else {
|
|
position++
|
|
}
|
|
|
|
position = (position + 100) % 100
|
|
|
|
if position == 0 {
|
|
zeroPasses++
|
|
}
|
|
}
|
|
|
|
if position == 0 {
|
|
zeroCount++
|
|
}
|
|
|
|
fmt.Println()
|
|
}
|
|
}
|
|
|
|
fmt.Println(zeroCount)
|
|
fmt.Println(zeroPasses)
|
|
}
|
|
}
|