You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
568 B

package day10
import (
"sort"
"strconv"
"git.elis.nu/etu/aoc2020/utils"
)
var rows []int
func ParseFile(input string) {
// Add zero as start number
rows = append(rows, 0)
// Parse file
for _, line := range utils.GetLinesFromFile("day10/" + input + ".txt") {
num, _ := strconv.Atoi(line)
rows = append(rows, num)
}
// Sort the numbers, will always be needed. And is required for calculation of consolues jolt usage below.
sort.Ints(rows)
// Add the consoles jolt usage by taking the last number plus 3
rows = append(rows, rows[len(rows)-1]+3)
}