If a @ is surrounded by less than four other @s, it can be removed. Nothing complicated about that. I guess the intention is for the code to be potentially tedious. For each slot, you need to check all 8 neighbors, and any one of them could be out of bounds. So the logic could get big. I think the simplest approach is a wrapper function that returns 0 if a slot is either empty or OOB, and 1 if it has @. Then use 8 calls to this function to count the neighbors of each spot.