2025 Day 1 Complete! 🎅

This commit is contained in:
2025-12-01 06:45:25 -06:00
parent 8e5e6a54fd
commit d51c0d74d7
4 changed files with 4383 additions and 0 deletions

57
2025/day01/main.go Normal file
View File

@@ -0,0 +1,57 @@
package main
import (
"fmt"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
func main() {
inp := h.StdinToStringSlice()
part1(inp)
part2(inp)
}
func part1(inp []string) {
var hit int
dial := 50
for i := range inp {
dir, snum := inp[i][0], inp[i][1:]
num := h.Atoi(snum)
switch dir {
case 'R':
dial += num
case 'L':
dial -= num
}
dial = (dial + 100) % 100
if dial == 0 {
hit++
}
}
fmt.Println("# Part 1")
fmt.Println(hit)
}
func part2(inp []string) {
var hit int
dial := 50
for i := range inp {
dir, snum := inp[i][0], inp[i][1:]
num := h.Atoi(snum)
for j := 0; j < num; j++ {
switch dir {
case 'R':
dial = (dial + 1) % 100
case 'L':
dial = (dial - 1 + 100) % 100
}
if dial == 0 {
hit++
}
}
}
fmt.Println("# Part 2")
fmt.Println(hit)
}