Skip to content

Commit f5cb1c3

Browse files
committed
Fix clang format errors
1 parent d1024ab commit f5cb1c3

File tree

2 files changed

+14
-30
lines changed

2 files changed

+14
-30
lines changed

src/main/java/com/thealgorithms/others/Sudoku.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* A class that provides methods to solve a 9x9 Sudoku puzzle using a backtracking approach.
5-
* The Sudoku board is represented as a 2D array, and the methods are designed to
5+
* The Sudoku board is represented as a 2D array, and the methods are designed to
66
* check for safe placements of numbers, solve the puzzle recursively, and print the board.
77
*/
88
final class Sudoku {

src/test/java/com/thealgorithms/others/SudokuTest.java

+13-29
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

5+
import java.util.stream.Stream;
56
import org.junit.jupiter.params.ParameterizedTest;
7+
import org.junit.jupiter.params.provider.Arguments;
68
import org.junit.jupiter.params.provider.CsvSource;
79
import org.junit.jupiter.params.provider.MethodSource;
8-
import org.junit.jupiter.params.provider.Arguments;
910

10-
import java.util.stream.Stream;
1111

1212
public class SudokuTest {
1313

@@ -17,30 +17,15 @@ public class SudokuTest {
1717
*/
1818
static Stream<Arguments> provideSudokuBoards() {
1919
return Stream.of(
20-
Arguments.of(new int[][]{
21-
{5, 3, 0, 0, 7, 0, 0, 0, 0},
22-
{6, 0, 0, 1, 9, 5, 0, 0, 0},
23-
{0, 9, 8, 0, 0, 0, 0, 6, 0},
24-
{8, 0, 0, 0, 6, 0, 0, 0, 3},
25-
{4, 0, 0, 8, 0, 3, 0, 0, 1},
26-
{7, 0, 0, 0, 2, 0, 0, 0, 6},
27-
{0, 6, 0, 0, 0, 0, 2, 8, 0},
28-
{0, 0, 0, 4, 1, 9, 0, 0, 5},
29-
{0, 0, 0, 0, 8, 0, 0, 7, 9}
30-
}, true),
20+
Arguments.of(
21+
new int[][] {{5, 3, 0, 0, 7, 0, 0, 0, 0}, {6, 0, 0, 1, 9, 5, 0, 0, 0}, {0, 9, 8, 0, 0, 0, 0, 6, 0}, {8, 0, 0, 0, 6, 0, 0, 0, 3}, {4, 0, 0, 8, 0, 3, 0, 0, 1}, {7, 0, 0, 0, 2, 0, 0, 0, 6}, {0, 6, 0, 0, 0, 0, 2, 8, 0}, {0, 0, 0, 4, 1, 9, 0, 0, 5}, {0, 0, 0, 0, 8, 0, 0, 7, 9}}, true),
3122

32-
Arguments.of(new int[][]{
33-
{5, 3, 0, 0, 7, 0, 0, 0, 0},
34-
{6, 0, 0, 1, 9, 5, 0, 0, 0},
35-
{0, 9, 8, 0, 0, 0, 0, 6, 0},
36-
{8, 0, 0, 0, 6, 0, 0, 0, 3},
37-
{4, 0, 0, 8, 0, 3, 0, 0, 1},
38-
{7, 0, 0, 0, 2, 0, 0, 0, 6},
39-
{0, 6, 0, 0, 0, 0, 2, 8, 0},
40-
{0, 0, 0, 4, 1, 9, 0, 0, 5},
23+
Arguments.of(
24+
new int[][] {
25+
{5, 3, 0, 0, 7, 0, 0, 0, 0}, {6, 0, 0, 1, 9, 5, 0, 0, 0}, {0, 9, 8, 0, 0, 0, 0, 6, 0}, {8, 0, 0, 0, 6, 0, 0, 0, 3}, {4, 0, 0, 8, 0, 3, 0, 0, 1}, {7, 0, 0, 0, 2, 0, 0, 0, 6}, {0, 6, 0, 0, 0, 0, 2, 8, 0}, {0, 0, 0, 4, 1, 9, 0, 0, 5},
4126
{0, 0, 0, 0, 8, 0, 0, 7, 7} // Invalid board (duplicate '7' in the last row)
42-
}, false)
43-
);
27+
},
28+
false));
4429
}
4530

4631
/**
@@ -67,11 +52,10 @@ void testSolveSudoku(int[][] board, boolean expectedResult) {
6752
* @param expectedResult True if the placement is valid, false otherwise.
6853
*/
6954
@ParameterizedTest
70-
@CsvSource({
71-
"'5,3,0,0,7,0,0,0,0;6,0,0,1,9,5,0,0,0;0,9,8,0,0,0,0,6,0;8,0,0,0,6,0,0,0,3;4,0,0,8,0,3,0,0,1;7,0,0,0,2,0,0,0,6;0,6,0,0,0,0,2,8,0;0,0,0,4,1,9,0,0,5;0,0,0,0,8,0,0,7,9', 0, 2, 4, false",
72-
"'5,3,0,0,7,0,0,0,0;6,0,0,1,9,5,0,0,0;0,9,8,0,0,0,0,6,0;8,0,0,0,6,0,0,0,3;4,0,0,8,0,3,0,0,1;7,0,0,0,2,0,0,0,6;0,6,0,0,0,0,2,8,0;0,0,0,4,1,9,0,0,5;0,0,0,0,8,0,0,7,9', 0, 2, 9, true"
73-
})
74-
void testIsSafe(String boardString, int row, int col, int num, boolean expectedResult) {
55+
@CsvSource({"'5,3,0,0,7,0,0,0,0;6,0,0,1,9,5,0,0,0;0,9,8,0,0,0,0,6,0;8,0,0,0,6,0,0,0,3;4,0,0,8,0,3,0,0,1;7,0,0,0,2,0,0,0,6;0,6,0,0,0,0,2,8,0;0,0,0,4,1,9,0,0,5;0,0,0,0,8,0,0,7,9', 0, 2, 4, false",
56+
"'5,3,0,0,7,0,0,0,0;6,0,0,1,9,5,0,0,0;0,9,8,0,0,0,0,6,0;8,0,0,0,6,0,0,0,3;4,0,0,8,0,3,0,0,1;7,0,0,0,2,0,0,0,6;0,6,0,0,0,0,2,8,0;0,0,0,4,1,9,0,0,5;0,0,0,0,8,0,0,7,9', 0, 2, 9, true"})
57+
void
58+
testIsSafe(String boardString, int row, int col, int num, boolean expectedResult) {
7559
int[][] board = parseBoard(boardString);
7660
assertEquals(expectedResult, Sudoku.isSafe(board, row, col, num));
7761
}

0 commit comments

Comments
 (0)