Compare commits
2 Commits
ac6abe0ced
...
3c371cbedf
| Author | SHA1 | Date |
|---|---|---|
|
|
3c371cbedf | |
|
|
5dc42aa8e6 |
|
|
@ -0,0 +1,4 @@
|
|||
*/input.txt
|
||||
*/dummy_input.txt
|
||||
*/Cargo.lock
|
||||
*/target/
|
||||
|
|
@ -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á
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
Loading…
Reference in New Issue