aoc2024/day-09/internal/two/block.go

34 lines
534 B
Go
Raw Normal View History

2024-12-10 21:42:26 +00:00
package two
import "fmt"
type kind int
const (
kindOfFile kind = iota
kindOfEmpty
)
2024-12-10 21:42:26 +00:00
type block struct {
kind kind
id int
start int
length int
value int
2024-12-10 21:42:26 +00:00
}
func newBlock(kind kind, id, start, length, value int) *block {
return &block{kind, id, start, length, value}
2024-12-10 21:42:26 +00:00
}
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)
2024-12-10 21:42:26 +00:00
}