Every cell in that grid is one of the 1,296 possible codes. Each guess eliminates the ones that could not have produced the feedback you got, and they go dark. Perfect play needs five guesses at worst — the solver here is Knuth's 1977 minimax, which picks whichever guess leaves the smallest worst-case set of survivors.