diff --git a/2025/day/1/part2/go.mod b/2025/day/1/part2/go.mod new file mode 100644 index 0000000..e4c7d61 --- /dev/null +++ b/2025/day/1/part2/go.mod @@ -0,0 +1,3 @@ +module part2 + +go 1.23.4 diff --git a/2025/day/1/part2/part2.go b/2025/day/1/part2/part2.go new file mode 100644 index 0000000..acb68fb --- /dev/null +++ b/2025/day/1/part2/part2.go @@ -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) +}