This commit is contained in:
Simon Ziegler
2025-12-01 15:03:10 +01:00
parent 35f75813de
commit 15935d3f23
5 changed files with 4531 additions and 0 deletions

54
01/main.go Normal file
View File

@@ -0,0 +1,54 @@
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)
}
}