Day 14 & 15 progress
This commit is contained in:
@@ -3,7 +3,11 @@ package intcodeprocessor
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
helpers "git.bullercodeworks.com/brian/adventofcode/helpers"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -48,6 +52,20 @@ type Program struct {
|
||||
debug bool
|
||||
}
|
||||
|
||||
func ReadIntCodeFile(fn string) []int {
|
||||
dat, err := ioutil.ReadFile(fn)
|
||||
if err != nil {
|
||||
fmt.Println("Error reading program file:", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
var prog []int
|
||||
stringDat := strings.TrimSpace(string(dat))
|
||||
for _, v := range strings.Split(stringDat, ",") {
|
||||
prog = append(prog, helpers.Atoi(v))
|
||||
}
|
||||
return prog
|
||||
}
|
||||
|
||||
func NewProgram(prog []int) *Program {
|
||||
p := new(Program)
|
||||
p.originalCode = make([]int, len(prog))
|
||||
|
Reference in New Issue
Block a user