int numberOfNeighbors(location l, int m, int n){ int count = 0; for (int i = 0; i < 8; i++) if (withinBounds(l + offset[i], m, n)) count++; return count; }