/** Dominoes by Jeffrey K. Brown A friend who is a mathematician and I came across a problem that went like this: If you had an 8 x 8 chessboard, you can lay 32 dominoes on the board in such a way that each domino occupies two squares. Suppose you cut off two diagonally opposing corners. Can 31 dominoes be arranged on the board? We weren't sure of the answer, and decided to take a crack at it. I wanted to solve it with a program, he wanted to figure it out mathematically. I wrote this program and set it in motion for a smaller set, a 4x4 board. It didn't take long to write. Shortly after we set it in motion, my friend and I discovered that you could not do it, because each domino must take up one black and one white square. Opposing corners on a chessboard are the same color, so it couldn't be done. I also ran across a library called Apache POI (for Poor Obfuscation Implementation), which allows a Java program to write to Excel spreadsheets. I decided to try out the POI library on my Dominoes program and have the combinations printed to Excel. Unfortunately, we ran out of memory before we printed all of the combinations, but I did figure out how POI worked as a result. I have plenty of memory if I do a smaller chessboard and the Excel printing works just fine. It's an interesting program although its no longer needed since I have the answer. */ import java.util.*; import java.io.*; import org.apache.poi.hssf.usermodel.*; /** Dominoes This program will simulate the dominoes on a chessboard problem. */ public class Dominoes { // Blocks Per Side static final int block=4; // We build the board based on Blocks Per Side int board[][] = new int[block][block]; // Here, we set up the Excel Variables FileOutputStream excel=null; HSSFWorkbook wb=null; HSSFSheet sheet=null; HSSFRow row = null; boolean reporting=false; long rownum=0; /** Constructor. Simply clear out the Board */ public Dominoes() { int i=0; int j=0; for (i=0; i