1. In order to implement Board, we first have to learn how to manipulate bits. Write a method printBits which takes integer n as input. It prints out the bits of n as follows. Do the following nine times. If n is even, print "0". If n is odd, print "1". Divide n by 2. In a loop in main, run printBits on the integers from 0 to 9 and print the results: 0 000000000 1 100000000 2 010000000 3 110000000 4 001000000 5 101000000 6 011000000 7 111000000 8 000100000 9 100100000 Those of you who know about base 2 might notice that we are just printing the binary representation of n BACKWARDS. 2. Now write a method bitOperations that reads in two integers a and b and prints their bits along with a&b and a|b. These are bitwise AND and bitwise OR. Call it four times from main. Enter a: 6 a = 011000000 Enter b: 5 b = 101000000 a & b = 001000000 a | b = 111000000 a & b is 001000000 because they only both have 1 in the third position. a | b is 111000000 because a or b has a 1 in the first three positions. Enter a: 5 a = 101000000 Enter b: 1 b = 100000000 a & b = 100000000 a | b = 101000000 Enter a: 5 a = 101000000 Enter b: 2 b = 010000000 a & b = 000000000 a | b = 111000000 Enter a: 5 a = 101000000 Enter b: 4 b = 001000000 a & b = 001000000 a | b = 101000000 Powers of 2 have a 1 in one position an zeros everywhere else. They are like powers of 10 in base 10. You can use & and a power of 2 to check if a particular bit is set. You can use | and a power of 2 to set a particular bit. 3. The positions in the Sudoku board are number left to right, top to bottom, from 0 to 80. There are 9 rows numbered 0 to 8. Ditto columns. Write methods getRow(pos) and getCol(pos) which return the row and column of a position. Hint: use / and %. Write a method getPos(row, col) which converts the row and column back into the position. a. pos divided by 9 gives quotient row and remainder col. Example: pos 32 is in row 3 (the fourth row) and col 5 because 32 divided by 9 has quotient 3 and remainder 5. Check: 9*3+5=32. b. X divided by 9 has quotient row and remainder col. What is X? Test in main: for (int pos = 0; pos < 81; pos++) { int row = getRow(pos); int col = getCol(pos); System.out.println("pos " + pos); System.out.println(" row " + row); System.out.println(" col " + col); System.out.println(" pos " + getPos(row, col)); } pos 0 row 0 col 0 pos 0 pos 1 row 0 col 1 pos 1 pos 2 row 0 col 2 pos 2 pos 3 row 0 col 3 pos 3 pos 4 row 0 col 4 pos 4 pos 5 row 0 col 5 pos 5 pos 6 row 0 col 6 pos 6 pos 7 row 0 col 7 pos 7 pos 8 row 0 col 8 pos 8 pos 9 row 1 col 0 pos 9 pos 10 row 1 col 1 pos 10 pos 11 row 1 col 2 pos 11 pos 12 row 1 col 3 pos 12 pos 13 row 1 col 4 pos 13 pos 14 row 1 col 5 pos 14 pos 15 row 1 col 6 pos 15 pos 16 row 1 col 7 pos 16 pos 17 row 1 col 8 pos 17 pos 18 row 2 col 0 pos 18 pos 19 row 2 col 1 pos 19 pos 20 row 2 col 2 pos 20 pos 21 row 2 col 3 pos 21 pos 22 row 2 col 4 pos 22 pos 23 row 2 col 5 pos 23 pos 24 row 2 col 6 pos 24 pos 25 row 2 col 7 pos 25 pos 26 row 2 col 8 pos 26 pos 27 row 3 col 0 pos 27 pos 28 row 3 col 1 pos 28 pos 29 row 3 col 2 pos 29 pos 30 row 3 col 3 pos 30 pos 31 row 3 col 4 pos 31 pos 32 row 3 col 5 pos 32 pos 33 row 3 col 6 pos 33 pos 34 row 3 col 7 pos 34 pos 35 row 3 col 8 pos 35 pos 36 row 4 col 0 pos 36 pos 37 row 4 col 1 pos 37 pos 38 row 4 col 2 pos 38 pos 39 row 4 col 3 pos 39 pos 40 row 4 col 4 pos 40 pos 41 row 4 col 5 pos 41 pos 42 row 4 col 6 pos 42 pos 43 row 4 col 7 pos 43 pos 44 row 4 col 8 pos 44 pos 45 row 5 col 0 pos 45 pos 46 row 5 col 1 pos 46 pos 47 row 5 col 2 pos 47 pos 48 row 5 col 3 pos 48 pos 49 row 5 col 4 pos 49 pos 50 row 5 col 5 pos 50 pos 51 row 5 col 6 pos 51 pos 52 row 5 col 7 pos 52 pos 53 row 5 col 8 pos 53 pos 54 row 6 col 0 pos 54 pos 55 row 6 col 1 pos 55 pos 56 row 6 col 2 pos 56 pos 57 row 6 col 3 pos 57 pos 58 row 6 col 4 pos 58 pos 59 row 6 col 5 pos 59 pos 60 row 6 col 6 pos 60 pos 61 row 6 col 7 pos 61 pos 62 row 6 col 8 pos 62 pos 63 row 7 col 0 pos 63 pos 64 row 7 col 1 pos 64 pos 65 row 7 col 2 pos 65 pos 66 row 7 col 3 pos 66 pos 67 row 7 col 4 pos 67 pos 68 row 7 col 5 pos 68 pos 69 row 7 col 6 pos 69 pos 70 row 7 col 7 pos 70 pos 71 row 7 col 8 pos 71 pos 72 row 8 col 0 pos 72 pos 73 row 8 col 1 pos 73 pos 74 row 8 col 2 pos 74 pos 75 row 8 col 3 pos 75 pos 76 row 8 col 4 pos 76 pos 77 row 8 col 5 pos 77 pos 78 row 8 col 6 pos 78 pos 79 row 8 col 7 pos 79 pos 80 row 8 col 8 pos 80 4. There are 9 boxes in the Sudoku board. Write getBox(row, col) which returns the box for a given row and column. Hint: since the box is the same for groups of three rows and columns, divide row and col by 3. Now calculate the box similar to how you calculated the position from the row and col. Write getBox(pos). It's easy because you can use getRow(pos), getCol(pos), and getBox(row, col). Test in main: pos 0 row 0 col 0 pos 0 box 0 pos 1 row 0 col 1 pos 1 box 0 pos 2 row 0 col 2 pos 2 box 0 pos 3 row 0 col 3 pos 3 box 1 pos 4 row 0 col 4 pos 4 box 1 pos 5 row 0 col 5 pos 5 box 1 pos 6 row 0 col 6 pos 6 box 2 pos 7 row 0 col 7 pos 7 box 2 pos 8 row 0 col 8 pos 8 box 2 pos 9 row 1 col 0 pos 9 box 0 pos 10 row 1 col 1 pos 10 box 0 pos 11 row 1 col 2 pos 11 box 0 pos 12 row 1 col 3 pos 12 box 1 pos 13 row 1 col 4 pos 13 box 1 pos 14 row 1 col 5 pos 14 box 1 pos 15 row 1 col 6 pos 15 box 2 pos 16 row 1 col 7 pos 16 box 2 pos 17 row 1 col 8 pos 17 box 2 pos 18 row 2 col 0 pos 18 box 0 pos 19 row 2 col 1 pos 19 box 0 pos 20 row 2 col 2 pos 20 box 0 pos 21 row 2 col 3 pos 21 box 1 pos 22 row 2 col 4 pos 22 box 1 pos 23 row 2 col 5 pos 23 box 1 pos 24 row 2 col 6 pos 24 box 2 pos 25 row 2 col 7 pos 25 box 2 pos 26 row 2 col 8 pos 26 box 2 pos 27 row 3 col 0 pos 27 box 3 pos 28 row 3 col 1 pos 28 box 3 pos 29 row 3 col 2 pos 29 box 3 pos 30 row 3 col 3 pos 30 box 4 pos 31 row 3 col 4 pos 31 box 4 pos 32 row 3 col 5 pos 32 box 4 pos 33 row 3 col 6 pos 33 box 5 pos 34 row 3 col 7 pos 34 box 5 pos 35 row 3 col 8 pos 35 box 5 pos 36 row 4 col 0 pos 36 box 3 pos 37 row 4 col 1 pos 37 box 3 pos 38 row 4 col 2 pos 38 box 3 pos 39 row 4 col 3 pos 39 box 4 pos 40 row 4 col 4 pos 40 box 4 pos 41 row 4 col 5 pos 41 box 4 pos 42 row 4 col 6 pos 42 box 5 pos 43 row 4 col 7 pos 43 box 5 pos 44 row 4 col 8 pos 44 box 5 pos 45 row 5 col 0 pos 45 box 3 pos 46 row 5 col 1 pos 46 box 3 pos 47 row 5 col 2 pos 47 box 3 pos 48 row 5 col 3 pos 48 box 4 pos 49 row 5 col 4 pos 49 box 4 pos 50 row 5 col 5 pos 50 box 4 pos 51 row 5 col 6 pos 51 box 5 pos 52 row 5 col 7 pos 52 box 5 pos 53 row 5 col 8 pos 53 box 5 pos 54 row 6 col 0 pos 54 box 6 pos 55 row 6 col 1 pos 55 box 6 pos 56 row 6 col 2 pos 56 box 6 pos 57 row 6 col 3 pos 57 box 7 pos 58 row 6 col 4 pos 58 box 7 pos 59 row 6 col 5 pos 59 box 7 pos 60 row 6 col 6 pos 60 box 8 pos 61 row 6 col 7 pos 61 box 8 pos 62 row 6 col 8 pos 62 box 8 pos 63 row 7 col 0 pos 63 box 6 pos 64 row 7 col 1 pos 64 box 6 pos 65 row 7 col 2 pos 65 box 6 pos 66 row 7 col 3 pos 66 box 7 pos 67 row 7 col 4 pos 67 box 7 pos 68 row 7 col 5 pos 68 box 7 pos 69 row 7 col 6 pos 69 box 8 pos 70 row 7 col 7 pos 70 box 8 pos 71 row 7 col 8 pos 71 box 8 pos 72 row 8 col 0 pos 72 box 6 pos 73 row 8 col 1 pos 73 box 6 pos 74 row 8 col 2 pos 74 box 6 pos 75 row 8 col 3 pos 75 box 7 pos 76 row 8 col 4 pos 76 box 7 pos 77 row 8 col 5 pos 77 box 7 pos 78 row 8 col 6 pos 78 box 8 pos 79 row 8 col 7 pos 79 box 8 pos 80 row 8 col 8 pos 80 box 8 5. Write getRowPositions(row) which returns an array of 9 integers containing the positions on the given row. To do this: a. Create an array positions of int of length 9. b. Iterate col from 0 to 8. c. Put getPos(row, col) into positions[col]. d. Return positions. Test by calling getRow(pos) for each position in the array. In main: for (int row = 0; row < 9; row++) { System.out.print("row " + row + ":"); int[] positions = getRowPositions(row); for (int pos : positions) System.out.print(" " + pos); System.out.println(); } row 0: 0 1 2 3 4 5 6 7 8 row 1: 9 10 11 12 13 14 15 16 17 row 2: 18 19 20 21 22 23 24 25 26 row 3: 27 28 29 30 31 32 33 34 35 row 4: 36 37 38 39 40 41 42 43 44 row 5: 45 46 47 48 49 50 51 52 53 row 6: 54 55 56 57 58 59 60 61 62 row 7: 63 64 65 66 67 68 69 70 71 row 8: 72 73 74 75 76 77 78 79 80 6. Ditto getColPositions. col 1: 1 10 19 28 37 46 55 64 73 col 2: 2 11 20 29 38 47 56 65 74 col 3: 3 12 21 30 39 48 57 66 75 col 4: 4 13 22 31 40 49 58 67 76 col 5: 5 14 23 32 41 50 59 68 77 col 6: 6 15 24 33 42 51 60 69 78 col 7: 7 16 25 34 43 52 61 70 79 col 8: 8 17 26 35 44 53 62 71 80 7. getBoxPositions is trickier. I'll go over how to do it in class. But if you want to get started on the homework, give it a shot.