mirror of
				https://github.com/onyx-and-iris/aoc2024.git
				synced 2025-11-03 22:41:46 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			534 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			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)
 | 
						|
}
 |