public static void alternatingBoard(String[][] strs) {
	// For every row...
	for (int row = 0; row < strs.length; row++) {
		// ... and every column...
		for (int col = 0; col < strs[0].length; col++) {
			// If the row plus the column is even then
			// assign "X" as the array element; "O" if odd
			//
			// This one line does the work of the commented out
			// if-else structure below it. The general form is:
			//   predicate ? true-value : false-value
			strs[row][col] = ((row+col) % 2 == 0) ? "X" : "O";
//			if ((row + col) % 2 == 0) {
//				strs[row][col] = "X";
//			} else {
//				strs[row][col] = "O";
//			}
		}
	}
}



// Helper function; returns true if n is between low and high, inclusive
public static boolean between(int n, int low, int high) {
	return n >= low && n <= high;
}

public static int[][] neighbors(boolean[][] grid) {		
	// Create an array of ints that corresponds in size to the grid
	int[][] neighbors = new int[grid.length][grid[0].length];
	
	// For every row...
	for (int row = 0; row < neighbors.length; row++) {
		// ... and every column...
		for (int col = 0; col < neighbors[0].length; col++) {
			// Start out by setting the number of neighbors to zero and
			// then start counting
			int n = 0;
			// For the rows one above to one below...
			for (int r = row-1; r <= row+1; r++) {
				// ... and the columns from one to the left to one to the right...
				for (int c = col-1; c <= col+1; c++) {
					// Make sure the (row, col) coordinates are legal indexes!
					if (between(r, 0, neighbors.length-1) &&
						between(c, 0, neighbors[0].length-1)) {
						// Make sure that we aren't asking the square itself
						// if it's a neighbor!
						if (r != row || c != col) {
							// Add one to the neighbors count if grid[r][c] is true
							n += grid[r][c] ? 1 : 0;
						}
					}					
				}
			}
			
			// Assign the number of neighbors
			neighbors[row][col] = n;
		}
	}
	
	// Return the array
	return neighbors;
}