From 0fb4fe3a04784ec811cc959e150f28c7a0551a49 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:34:53 +0100 Subject: [PATCH] refactoring: 9 --- src/main/c/sudoku.c | 256 ++++++++++++++++++++++---------------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 21fba11..1b134a1 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -38,88 +38,88 @@ int availableLevels[3][3][SIZE_OF_GAMEBORD_AXIS_X][SIZE_OF_GAMEBORD_AXIS_Y] = { {0, 4, 8, 2, 0, 9, 5, 0, 0}, {5, 0, 0, 7, 0, 3, 2, 0, 0}}, - {{0, 0, 3, 0, 2, 1, 8, 0, 0}, - {6, 0, 0, 0, 7, 0, 1, 3, 2}, - {9, 2, 1, 5, 0, 0, 7, 6, 4}, - {7, 6, 0, 3, 0, 0, 4, 0, 0}, - {8, 5, 4, 1, 9, 7, 0, 0, 0}, - {1, 0, 0, 4, 0, 6, 0, 0, 0}, - {2, 9, 0, 8, 1, 5, 0, 0, 6}, - {0, 4, 8, 2, 0, 9, 5, 0, 0}, - {5, 0, 0, 7, 0, 3, 2, 0, 2}}, - - {{0, 0, 3, 0, 2, 1, 8, 0, 0}, - {6, 0, 0, 0, 7, 0, 1, 3, 2}, - {9, 2, 1, 5, 0, 0, 7, 6, 4}, - {7, 6, 0, 3, 0, 0, 4, 0, 0}, - {8, 5, 4, 1, 9, 7, 0, 0, 0}, - {1, 0, 0, 4, 0, 6, 0, 0, 0}, - {2, 9, 0, 8, 1, 5, 0, 0, 6}, - {0, 4, 8, 2, 0, 9, 5, 0, 0}, - {5, 0, 0, 7, 0, 3, 2, 0, 0}}}, + {{7, 0, 2, 0, 0, 0, 9, 5, 0}, + {0, 8, 0, 7, 5, 0, 2, 1, 6}, + {0, 0, 5, 5, 2, 8, 7, 0, 3}, + {5, 1, 8, 4, 3, 0, 6, 0, 0}, + {0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