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

32 lines
499 B

package day08
import (
"regexp"
"strconv"
"git.elis.nu/etu/aoc2020/utils"
)
type Operation struct {
Operation string
Argument int
}
var rows []Operation
func ParseFile(input string) {
// Parse file
for _, line := range utils.GetLinesFromFile("day08/" + input + ".txt") {
re := regexp.MustCompile(`^(\w+) (.\d+)$`)
matches := re.FindStringSubmatch(line)
arg, _ := strconv.Atoi(matches[2])
rows = append(rows, Operation{
Operation: matches[1],
Argument: arg,
})
}
}