aoc2020/day13/parse.go

36 lines
579 B
Go

package day13
import (
"strconv"
"strings"
"git.elis.nu/etu/aoc2020/utils"
)
var schedule struct {
Departure int
Lines map[int]int
}
func ParseFile(input string) {
// Parse file
rows := utils.GetLinesFromFile("day13/" + input + ".txt")
// Convert time
time, _ := strconv.Atoi(rows[0])
// Store time
schedule.Departure = time
schedule.Lines = make(map[int]int)
for offset, row := range strings.Split(rows[1], ",") {
if row != "x" {
// Convert bus number
line, _ := strconv.Atoi(row)
// Add to schedule
schedule.Lines[offset] = line
}
}
}