2024 day 12 Complete!
This commit is contained in:
@@ -249,6 +249,22 @@ func (m *CoordByteMap) InsertColAfter(col int, fill byte) {
|
||||
}
|
||||
}
|
||||
|
||||
// FindAllUnique searches the whole map and returns a slice of all unique bytes
|
||||
func (m *CoordByteMap) FindAllUnique() []byte {
|
||||
var ret []byte
|
||||
track := make(map[byte]bool)
|
||||
for y := m.TLY; y <= m.BRY; y++ {
|
||||
for x := m.TLX; x <= m.BRX; x++ {
|
||||
c := Coordinate{X: x, Y: y}
|
||||
if !track[m.Get(c)] {
|
||||
ret = append(ret, m.Get(c))
|
||||
track[m.Get(c)] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// FindFirst searches left to right, top to bottom for the first
|
||||
// instance of b.
|
||||
func (m *CoordByteMap) FindFirst(b byte) (Coordinate, error) {
|
||||
|
Reference in New Issue
Block a user