From de3599c1f09797617f18114af70e62dbf6f4aa25 Mon Sep 17 00:00:00 2001 From: fdai6499 Date: Fri, 11 Nov 2022 15:41:06 +0100 Subject: [PATCH] implemented a idea of how to make a simple sudoku --- ProjectDiary.md | 2 -- sudokuExample/src/Main.java | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 sudokuExample/src/Main.java diff --git a/ProjectDiary.md b/ProjectDiary.md index 13f661a..e69de29 100644 --- a/ProjectDiary.md +++ b/ProjectDiary.md @@ -1,2 +0,0 @@ -Start -asjdbakjdsf \ No newline at end of file diff --git a/sudokuExample/src/Main.java b/sudokuExample/src/Main.java new file mode 100644 index 0000000..031de2e --- /dev/null +++ b/sudokuExample/src/Main.java @@ -0,0 +1,46 @@ +import java.util.Scanner; + +class Main { + + //sudoku counts from 1 to 9 - sCount + static final int SCOUNT = 9; + + static int field[][] = new int[SCOUNT][SCOUNT]; + + public static void main(String[] args) { + + while (true) { + int[] transaction = readInput(); + field[transaction[0]][transaction[1]] = transaction[2]; + output(field); + } + } + + private static void output(int[][] field) { + + for (int i = 0; i < SCOUNT; i++) { + for (int j = 0; j < SCOUNT; j++) { + System.out.print(field[i][j] + " "); + } + System.out.println(); + } + + } + + static int[] readInput() { + + Scanner scanner = new Scanner(System.in); + String line = scanner.nextLine(); + System.out.println(line); + + String substring = line.substring(line.indexOf('(')+1, line.indexOf(')')); + String[] split = substring.split(","); + + int[] transaction = new int[split.length]; + for (int i = 0; i < split.length; i++) { + transaction[i] = Integer.valueOf(split[i]); + } + + return transaction; + } +} \ No newline at end of file