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