8/8/2023 0 Comments Microsoft excel sudoku solverPrompt Paul's first statement is more helpful than it first appears Prompt Paul: I don't know what the numbers are Prompt There are 2 integers a and b between &minval and &maxval, with a= a.num Ĭreate view sums as select a+b s,count(*) ccĬreate view products as select a*b p,count(*) cc By the way, the answer is the same even if you make the largest value 1000 (and then solving by hand becomes a nightmare). I like this problem, since it is almost impossible to solve by hand. īy the way – if you like sql pluzzles you might like to try this, which can be solved by a single sql statement ( it will work even with Oracle 8i), assuming you have a table called nums that holds the values 2.100. These queries should work on every 10G database, but I have tested it only on 10.2.0.1.0, and I have heard that they won’t work on 10.2.0.3.0 This query can take some more time, up to 60 seconds. When length( v ) = 1 then iteration_numberĪnd that means: find the first unsolved cell, starting from cell j ( i = instr( s, ' ', j )įor this cell, check the values from the other cells on the same row, column, block and find the possible values for this cell with the translate, v = translate( '123456789'Īnd if only one value is possible we have solved this cell, s = caseĪnd do this again and again until we have solved the complete Sudoku or don’t find anything to solve rules iterate ( 100000 ) until ( length( replace( s, ' ' ) ) >= 81 or d + 81 = 81 ) When length( v ) = 1 then substr( s, 1, i - 1 ) || v || substr( s, i + 1 ) , r = case when x + cv(j) = 81 or d + 81 = 81 then 1 And that isn’t too much said! But how can you use it for solving Sudokus? Quit simple in fact, select it as a string from 81 characters from dual select ' 56 2 ' || The model clause is introduced in Oracle 10g and, according to the documentation “brings a new level of power and flexibility to SQL calculations”. I did already a blog on Solving a Sudoku with Collections, but for this blog I used another aproach: the model clause. Solving a Suduku with one SQL-statement, is that possible? A lot of people won’t believe it, but yes, it can be done.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |