aoc2024/day-09/internal/two/block.go
2024-12-19 12:54:40 +00:00

34 lines
534 B
Go

package two
import "fmt"
type kind int
const (
kindOfFile kind = iota
kindOfEmpty
)
type block struct {
kind kind
id int
start int
length int
value int
}
func newBlock(kind kind, id, start, length, value int) *block {
return &block{kind, id, start, length, value}
}
func (b *block) String() string {
var kindStr string
switch b.kind {
case kindOfFile:
kindStr = "file"
case kindOfEmpty:
kindStr = "empty"
}
return fmt.Sprintf("kind: %s id: %d start: %d length: %d", kindStr, b.id, b.start, b.length)
}