2024 day 12 Complete!

This commit is contained in:
2024-12-12 08:46:54 -06:00
parent 439412bac1
commit 7c4f208bb1
8 changed files with 348 additions and 0 deletions

View File

@@ -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) {