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.
 
 
 
aoc2020/day13/parse.go

35 lines
579 B

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
}
}
}