feat(2025: add day 1 part 2

This commit is contained in:
2025-12-01 22:10:06 +07:00
parent 7788554da9
commit 7f49236d21
2 changed files with 37 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
module part2
go 1.23.4
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
file, _ := os.Open("input.txt")
defer file.Close()
scanner := bufio.NewScanner(file)
current := 50
counter := 0
for scanner.Scan() {
line := scanner.Text()
direction := line[0]
multiplier := 1
if direction == 'L' {
multiplier = -1
}
number, _ := strconv.Atoi(line[1:])
for range number {
current += multiplier
current = ((current % 100) + 100) % 100
if current == 0 {
counter++
}
}
}
fmt.Printf("%d\n", counter)
}