I’m working on the Chessboard exercise, and I’ve gotten all the methods working except for CountInRank.
// CountInRank returns how many squares are occupied in the chessboard,
// within the given rank.
func CountInRank(cb Chessboard, rank int) int {
var num_occupied int = 0
if rank < 1 || rank > 8 {
return 0
} else {
for i, _ := range cb {
if cb[i][rank] == true {
num_occupied += 1
}
}
return num_occupied
}
}
This seems to me like it should hit all the files of the rank, and it seems to, but the returned counts are not matching the expected results.