Day 3 Part 1

main
kirbylife 2025-12-10 00:17:44 -06:00
parent 5dc42aa8e6
commit 3c371cbedf
2 changed files with 47 additions and 0 deletions

View File

@ -3,5 +3,7 @@
Este es mi intento para resolver todos¹ los problemas del [AOC 2025](https://adventofcode.com/).
Día 1: Rust
Día 2: Python
Día 3: Go
¹ Ojalá

45
day-3/main.go 100644
View File

@ -0,0 +1,45 @@
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func parseInput() []string {
raw_data, err := os.ReadFile("input.txt")
check(err)
data := string(raw_data[:])
lines := strings.Split(strings.TrimSpace(data), "\n")
return lines
}
func part1() {
output := 0
for _, bank := range parseInput() {
max := 0
for i, n1 := range bank[:len(bank)-1] {
for _, n2 := range bank[i+1:] {
new_value, err := strconv.Atoi(string(n1) + string(n2))
check(err)
if new_value > max {
max = new_value
}
}
}
output = output + max
}
fmt.Println(output)
}
func main() {
fmt.Println("Part 1:")
part1()
}