Starting to make library out of intcode processor (from day 2)
This commit is contained in:
3
2019/intcode-processor/go.mod
Normal file
3
2019/intcode-processor/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module intcode
|
||||
|
||||
go 1.13
|
19
2019/intcode-processor/processor.go
Normal file
19
2019/intcode-processor/processor.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user