33 lines
499 B
Go
33 lines
499 B
Go
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,
|
|
})
|
|
|
|
}
|
|
}
|