Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class antiSudoku {
- public static void main(String[] args) throws IOException {
- BufferedReader reader
- = new BufferedReader(new InputStreamReader(System.in));
- int tc = Integer.parseInt(reader.readLine());
- int y[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}, x[] = {0, 3, 6, 1, 4, 7, 2, 5, 8};
- char mat[][] = new char[9][9];
- for (int i = 0; i < tc; i++) {//sudoku
- for (int j = 0; j < 9; j++) {// Lines
- char arr[] = reader.readLine().toCharArray();
- for (int q = 0; q < 9; q++) {
- mat[j][q] = arr[q];
- }
- }
- for (int e = 0; e < 9; e++) {
- int number = Integer.parseInt(mat[y[e]][x[e]] + "");
- if (number < 9) {
- mat[y[e]][x[e]] = ((number + 1) + "").charAt(0);
- } else {
- mat[y[e]][x[e]] = ((number - 1) + "").charAt(0);
- }
- }
- for (int e = 0; e < 9; e++) {
- System.out.println(mat[e]);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment