Starting to make library out of intcode processor (from day 2)

This commit is contained in:
2019-12-04 09:02:34 -06:00
parent 4537c3b913
commit ed78ac855a
3 changed files with 27 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
module intcode
go 1.13

View File

@@ -0,0 +1,19 @@
package intcode
import "fmt"
type Program struct {
code []int
ptr int
}
func NewProgram(prog []int) *Program {
p := new(Program)
p.code = make([]int, len(prog))
copy(p.code, prog)
return p
}
func (p *Program) PrintCode() {
fmt.Println(code)
}