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

22 lines
289 B
Go

package two
const empty = -1
type block struct {
used int
free []int
offset int
}
func newBlock(used, start, end int) block {
return block{
used: used,
free: []int{start, start + end},
offset: 0,
}
}
func (b *block) available() int {
return b.free[1] - b.free[0]
}