2024 Apr 02 9:47 AM
I want to do blind scan for sudoku I want to print that condition for that row and column I want to make it very simple.
2024 Apr 02 10:07 AM
I know sudoku but what is "sudoku blind scan"?
2024 Apr 02 10:09 AM
Why did you select all tags containing ABAP? Why didn't you just select the unique tag "ABAP Development"?
2024 Apr 02 10:15 AM
2024 Apr 03 8:01 AM
For example, I will do 3 x 3 sudoku and with the values I set fixed in my program, the program will scan each row and column and give me the output when it places the appropriate numbers. so there will be no user interaction. I am looking for such a simple code, where can I actually find it?
2024 Apr 03 8:17 AM
Sudoku solving algorithms - Backtracking (brute-force search) - Wikipedia:
"A brute force algorithm visits the empty cells in some order, filling in digits sequentially, or backtracking when the number is found to be not valid. Briefly, a program would solve a puzzle by placing the digit "1" in the first cell and checking if it is allowed to be there. If there are no violations (checking row, column, and box constraints) then the algorithm advances to the next cell and places a "1" in that cell. When checking for violations, if it is discovered that the "1" is not allowed, the value is advanced to "2". If a cell is discovered where none of the 9 digits is allowed, then the algorithm leaves that cell blank and moves back to the previous cell. The value in that cell is then incremented by one. This is repeated until the allowed value in the last (81st) cell is discovered."
2024 Apr 03 8:30 AM
This is exactly what I wanted to say but I couldn't find a code like this. where can I find it?
2024 Apr 03 10:06 AM
2024 Apr 03 10:49 AM
I you weren't successfukl to find any sample in GitHub, check at https://www.geeksforgeeks.org/sudoku-backtracking-7/?ref=lbp there are samples in multiple languages (but not Abap)
2024 Apr 03 10:57 AM
You may translate the text into ABAP code yourself quite easily I guess. Something like 100 lines of code.
2024 Apr 05 9:58 AM
For information, for the fun, I could do the code from scratch in two hours by applying Sudoku solving algorithms - Backtracking (brute-force search) - Wikipedia), no need to convert C code.
"A brute force algorithm visits the empty cells in some order, filling in digits sequentially, or backtracking when the number is found to be not valid. Briefly, a program would solve a puzzle by placing the digit "1" in the first cell and checking if it is allowed to be there. If there are no violations (checking row, column, and box constraints) then the algorithm advances to the next cell and places a "1" in that cell. When checking for violations, if it is discovered that the "1" is not allowed, the value is advanced to "2". If a cell is discovered where none of the 9 digits is allowed, then the algorithm leaves that cell blank and moves back to the previous cell. The value in that cell is then incremented by one. This is repeated until the allowed value in the last (81st) cell is discovered."
To help you start and learn by yourself, here are the start and the end of the program. I didn't use any subroutine/method, just loops and conditions. It must be approximately 120 lines of code.
TYPES tv_row TYPE STANDARD TABLE OF i WITH EMPTY KEY.
TYPES tt_cell TYPE STANDARD TABLE OF tv_row WITH EMPTY KEY.
DATA(cells) = VALUE tt_cell(
( VALUE #( ( 5 ) ( 3 ) ( ) ( ) ( 7 ) ( ) ( ) ( ) ( ) ) )
( VALUE #( ( 6 ) ( ) ( ) ( 1 ) ( 9 ) ( 5 ) ( ) ( ) ( ) ) )
( VALUE #( ( ) ( 9 ) ( 8 ) ( ) ( ) ( ) ( ) ( 6 ) ( ) ) )
( VALUE #( ( 8 ) ( ) ( ) ( ) ( 6 ) ( ) ( ) ( ) ( 3 ) ) )
( VALUE #( ( 4 ) ( ) ( ) ( 8 ) ( ) ( 3 ) ( ) ( ) ( 1 ) ) )
( VALUE #( ( 7 ) ( ) ( ) ( ) ( 2 ) ( ) ( ) ( ) ( 6 ) ) )
( VALUE #( ( ) ( 6 ) ( ) ( ) ( ) ( ) ( 2 ) ( 8 ) ( ) ) )
( VALUE #( ( ) ( ) ( ) ( 4 ) ( 1 ) ( 9 ) ( ) ( ) ( 5 ) ) )
( VALUE #( ( ) ( ) ( ) ( ) ( 8 ) ( ) ( ) ( 7 ) ( 9 ) ) ) ).
DATA(backup_cells) = cells.
DATA(row_match) = 0.
DATA(row) = 1.
DATA(col) = 1.
DO.
" 0 means that the digit is to be determined
IF backup_cells[ row ][ col ] = 0.
...
ENDIF.
IF backup_cells[ row ][ col ] <> 0
OR digit_determination_succeeded = abap_true.
" go to the next cell
IF col < 9.
col = col + 1.
ELSEIF row = 9.
EXIT. " solved !
ELSE.
row = row + 1.
col = 1.
ENDIF.
ENDIF.
ENDDO.
ASSERT cells = VALUE tt_cell(
( VALUE #( ( 5 ) ( 3 ) ( 4 ) ( 6 ) ( 7 ) ( 8 ) ( 9 ) ( 1 ) ( 2 ) ) )
( VALUE #( ( 6 ) ( 7 ) ( 2 ) ( 1 ) ( 9 ) ( 5 ) ( 3 ) ( 4 ) ( 8 ) ) )
( VALUE #( ( 1 ) ( 9 ) ( 8 ) ( 3 ) ( 4 ) ( 2 ) ( 5 ) ( 6 ) ( 7 ) ) )
( VALUE #( ( 8 ) ( 5 ) ( 9 ) ( 7 ) ( 6 ) ( 1 ) ( 4 ) ( 2 ) ( 3 ) ) )
( VALUE #( ( 4 ) ( 2 ) ( 6 ) ( 8 ) ( 5 ) ( 3 ) ( 7 ) ( 9 ) ( 1 ) ) )
( VALUE #( ( 7 ) ( 1 ) ( 3 ) ( 9 ) ( 2 ) ( 4 ) ( 8 ) ( 5 ) ( 6 ) ) )
( VALUE #( ( 9 ) ( 6 ) ( 1 ) ( 5 ) ( 3 ) ( 7 ) ( 2 ) ( 8 ) ( 4 ) ) )
( VALUE #( ( 2 ) ( 8 ) ( 7 ) ( 4 ) ( 1 ) ( 9 ) ( 6 ) ( 3 ) ( 5 ) ) )
( VALUE #( ( 3 ) ( 4 ) ( 5 ) ( 2 ) ( 8 ) ( 6 ) ( 1 ) ( 7 ) ( 9 ) ) ) ).