29 lines
467 B
Go
29 lines
467 B
Go
package day01
|
|
|
|
import (
|
|
"log"
|
|
"sort"
|
|
"strconv"
|
|
|
|
"git.elis.nu/etu/aoc2020/utils"
|
|
)
|
|
|
|
var rows []int
|
|
|
|
func ParseFile(input string) {
|
|
// Parse file
|
|
for _, line := range utils.GetLinesFromFile("day01/" + input + ".txt") {
|
|
row, err := strconv.Atoi(line)
|
|
|
|
if err != nil {
|
|
log.Println("Failed to parse int, skipping:", err)
|
|
continue
|
|
}
|
|
|
|
rows = append(rows, row)
|
|
}
|
|
|
|
// To reach the end state in a more consistent manner, sort the input
|
|
sort.Ints(rows)
|
|
}
|