0. I put the solution Sudoku.java in your prog11 directory. Your job this week is to write MyBoard.java which does the same thing as VBoard. 1. A position on the board can have multiple possibilities. We will represent it as a binary string. So 101100011 has possibilities 1, 3, 4, 8, and 9 because those are the positions of the 1s. (It's not zero-based because Sudoku doesn't use 0 to 8.) val=1 has code 100000000, which is 1 val=2 has code 010000000, which is 2 val=3 has code 001000000, which is 4 val=4 has code 000100000, which is 8 val=5 has code 000010000, which is 16 val=6 has code 000001000, which is 32 val=7 has code 000000100, which is 64 val=8 has code 000000010, which is 128 val=9 has code 000000001, which is 256 public class MyBoard implements Board { private static final int[] code = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 256 }; private static final int ALL = 511; private int[] possibilities = new int[81]; As you can see, code[val] is the code for that value. ALL is 111111111, which is 511. possibilities is an array of int (of length 81). 2. Write a public constructor MyBoard() which initializes all entries in possibilities to ALL. Write the copy method which create a new Board and copies all the entries from this.possibilities into copy.possibilities. public Board copy () { MyBoard copy = new MyBoard(); // Copy all the entries from this.possibilities to copy.possibilities. } 3. Implement public boolean isPossible (int pos, int val) { It's just one line which returns true if the bit corresponding to the code of val is set at position pos in possibilities. Implement public int numPossible (int pos) { public int getOnePossible (int pos) { They call isPossible in a loop. 4. Copy getRowPositions(int row), getColPositions(int col), getBoxPositions(int box), and all the methods they depend on from your lab work to MyBoard. 5. Write the method that tells a position that a value is impossible for it (because some neighbor has been set to that value). private void setImpossible (int pos, int val) { Here is the logic: a. If value val is already impossible for position pos, then just return. b. Remove val as a possibility for position pos. For example, if possibilities[pos] is set to 101100011 and val is 3, then possibilities[pos] is set to 100100011. c. If the the number of possibilities for position pos is now exactly one, we need to inform the neighbors of position pos that they can no longer use THAT value val (not that same as the val in a and b). How can we do this? Call setValue(pos, val)!!! Yes, I know we haven't written setValue yet, but we WILL! 6. Write a method tellNeighbors that tells the neighbors of position pos that it has been set to value val, and so they should not use that value. private void tellNeighbors (int pos, int val, int[] neighbors) { The array neighbors is the row neighbors, col neighbors, or box neighbors of pos, and it includes the value pos, which we will have to skip. For each neighbor in neighbors, skipping neighbor==pos, call setImpossible(neighbor, val). 7. Now write public void setValue (int pos, int val) { Here is the logic: a. Make val the only possibility for position pos. For example, if possibilities[pos] is set to 101100011 and val is 3, the possibilities[pos] is set to 001000000. b. If you call getRowPositions(getRow(pos)), you get the row neighbors of pos. Similarly the col and box neighbors. Use tellNeighbors to tell these neighbors to remove value val as a possibility. Change VBoard to MyBoard in Sudoku.java. Test! 8. You program should work now, but it can be made faster. The problem is that you are calling getRowNeighbors(row) many many times with the same input row and getting the same output each time. It is better to call it just once and save the output in an array for later lookup. Create arrays of arrays to store these outputs: private static int[][] rowPositions = getRowPositions(); private static int[][] colPositions = getColPositions(); private static int[][] boxPositions = getBoxPositions(); The method private static int[][] getRowPositions () { creates the array of arrays and calls getRowPosition(row) to initialize arrayOfarrays[row] for each row. It then returns the array of arrays. Similarly, getColPositions and getBoxPositions. Finally, modify setValue to do the array lookup rowPositions[getRow(pos)] instead of the method call getRowPositions(getRow(pos)). Comment out the old code so you can change back. Do the same for box and col. Here is a nice way to get all the positions in a box. box --> boxcol and boxrow multiply both by 3 --> baserow and basecol interate i from 0 to 8 add i/3 to baserow and i%3 to basecol put the resulting position into positions[i]