// Name : Matthew Reeves // This is a program to verify sudoku puzzles import java.util.Scanner; public class mdreeves_Sudoku { public static void main ( String args[] ) { Scanner input = new Scanner ( System.in ); int r1c1, r1c2, r1c3, r1c4, r2c1, r2c2, r2c3, r2c4, r3c1, r3c2, r3c3, r3c4, r4c1, r4c2, r4c3, r4c4, tally; System.out.print ("\nWelcome to the Sudoku Checker v1.0! This program checks simple, small, 4x4 Sudoku grids for correctness. Each column, row and 2x2 region contains the numbers 1 through 4 only once. To check your Sudoku, enter your board one row at a time, with each digit separated by a space. Hit ENTER at the end of a row.\n\n"); System.out.print ("Enter Row 1: "); r1c1 = input.nextInt(); r1c2 = input.nextInt(); r1c3 = input.nextInt(); r1c4 = input.nextInt(); System.out.print ("Enter Row 2: "); r2c1 = input.nextInt(); r2c2 = input.nextInt(); r2c3 = input.nextInt(); r2c4 = input.nextInt(); System.out.print ("Enter Row 3: "); r3c1 = input.nextInt(); r3c2 = input.nextInt(); r3c3 = input.nextInt(); r3c4 = input.nextInt(); System.out.print ("Enter Row 4: "); r4c1 = input.nextInt(); r4c2 = input.nextInt(); r4c3 = input.nextInt(); r4c4 = input.nextInt(); tally=0; if (r1c1+r1c2+r2c1+r2c2==10) { System.out.print("\nREG-1:GOOD\n"); tally=tally+1; } else { System.out.print("\nREG-1:BAD\n"); } if (r3c1+r3c2+r4c1+r4c2==10) { System.out.print("REG-2:GOOD\n"); tally=tally+1; } else { System.out.print("REG-2:BAD\n"); } if (r1c3+r1c4+r2c3+r2c4==10) { System.out.print("REG-3:GOOD\n"); tally=tally+1; } else { System.out.print("REG-3:BAD\n"); } if (r3c3+r3c4+r4c3+r4c4==10) { System.out.print("REG-4:GOOD\n"); tally=tally+1; } else { System.out.print("REG-4:BAD\n"); } if (r1c1+r1c2+r1c3+r1c4==10) { System.out.print("\nROW-1:GOOD\n"); tally=tally+1; } else { System.out.print("\nROW-1:BAD\n"); } if (r2c1+r2c2+r2c3+r2c4==10) { System.out.print("ROW-2:GOOD\n"); tally=tally+1; } else { System.out.print("ROW-2:BAD\n"); } if (r3c1+r3c2+r3c3+r3c4==10) { System.out.print("ROW-3:GOOD\n"); tally=tally+1; } else { System.out.print("ROW-3:BAD\n"); } if (r4c1+r4c2+r4c3+r4c4==10) { System.out.print("ROW-4:GOOD\n"); tally=tally+1; } else { System.out.print("ROW-4:BAD\n"); } if (r1c1+r2c1+r3c1+r4c1==10) { System.out.print("\nCOL-1:GOOD\n"); tally=tally+1; } else { System.out.print("\nCOL-1:BAD\n"); } if (r1c2+r2c2+r3c2+r4c2==10) { System.out.print("COL-2:GOOD\n"); tally=tally+1; } else { System.out.print("COL-2:BAD\n"); } if (r1c3+r2c3+r3c3+r4c3==10) { System.out.print("COL-3:GOOD\n"); tally=tally+1; } else { System.out.print("COL-3:BAD\n"); } if (r1c4+r2c4+r3c4+r4c4==10) { System.out.print("COL-4:GOOD\n"); tally=tally+1; } else { System.out.print("COL-4:BAD\n"); } if (tally==12) { System.out.print("\nSUDO:VALID\n\n"); } else { System.out.print("\nSUDO:INVALID\n\n"); } } }