https://github.com/miou-zora/sudoku-java-ccursed
Sudoku solver using java stream
https://github.com/miou-zora/sudoku-java-ccursed
cursed java java-ccursed stream sudoku
Last synced: about 1 month ago
JSON representation
Sudoku solver using java stream
- Host: GitHub
- URL: https://github.com/miou-zora/sudoku-java-ccursed
- Owner: Miou-zora
- License: gpl-3.0
- Created: 2024-06-02T18:40:18.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-06-02T18:56:18.000Z (11 months ago)
- Last Synced: 2025-01-31T11:27:47.425Z (3 months ago)
- Topics: cursed, java, java-ccursed, stream, sudoku
- Language: Java
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sudoku-JAVA-ccursed
```java
static private boolean is_valid_sodoku(int [][] grid) {
return is_valid_predicate(grid, (row, col) -> col, (row, col) -> row) &&
is_valid_predicate(grid, (row, col) -> row, (row, col) -> col) &&
is_valid_predicate(grid, (row, col) -> (row / 3 + 3 * (col / 3)), (row, col) -> (row % 3 + 3 * (col % 3)));
}static private boolean is_valid_predicate(int [][] grid, BiFunction predi_row, BiFunction predi_col) {
return IntStream.range(0, grid.length)
.mapToObj(colIndex -> IntStream.range(0, grid[colIndex].length)
.mapToObj(rowIndex -> grid[predi_row.apply(rowIndex, colIndex)][predi_col.apply(rowIndex, colIndex)]))
.allMatch((row) -> row.distinct().mapToInt(i -> i).mapToObj(i -> i >= 1 && i <= 9).filter(i -> i).count() == 9);
}
```This project is a sudoku resolver written in Java using only streams.