#include ;~ #include ; download the most recent suitable DLL once and comment this out Local $hDB Local $aSudokus = [ _ ["Juvigy Med", "29 8 85 4 137 3 3 2 56 4 397 1 12 5 3 1 649 8 23 7 85"], _ ["Juvigy Hard", " 84 9 5 7 91 95 7 7 3 2 6 6 18 67 1 3 4 32 "], _ ["Juvigy Harder", " 934 2 7 3 1 4 2 6 7 9 5 63 4 7 6 4 8 1 8 2 "], _ ["MvGulik", " 23 9 8 6 1 38 5 4 3 2 4 6 3 7 8 1 3 8 78 9 6 2 5 14 "], _ ["Easy", "53 7 6 195 98 6 8 6 34 8 3 17 2 6 6 28 419 5 8 79"], _ ["Sqlite", "1 7 9 3 2 8 96 5 53 9 1 8 26 4 3 1 4 7 7 3 "], _ ["Hard", " 6 59 82 8 45 3 6 3 54 325 6 "], _ ["Hola", "4 2 3 1 6 5 299 1 42 8 9 1 5 85 3 861 5 4 2 4 5 7"], _ ["Hardest", "8 36 7 9 2 5 7 457 1 3 1 68 85 1 9 4 "], _ ["EasterMonster", "1 2 9 4 5 6 7 5 9 3 7 85 4 7 6 3 9 8 2 1"] _ ] _SQLite_Startup() $hDB = _SQLite_Open() Local $sTempCreate = "" & _ "create temporary table i (" & _ "i integer primary key, " & _ "name char, " & _ "word0, " & _ "word1, " & _ "peers0, " & _ "peers1)" & _ ";" & _ "insert into i " & _ "select i, " & _ "char(65+y)||(x+1) as name, " & _ "case when iword=0 then 1< i0 " & _ "and not (word0&w0 or word1&w1) " & _ "and ( " & _ "(w10&peers0 or w11&peers1) + " & _ "(w20&peers0 or w21&peers1) + " & _ "(w30&peers0 or w31&peers1) + " & _ "(w40&peers0 or w41&peers1) + " & _ "(w50&peers0 or w51&peers1) + " & _ "(w60&peers0 or w61&peers1) + " & _ "(w70&peers0 or w71&peers1) + " & _ "(w80&peers0 or w81&peers1) + " & _ "(w90&peers0 or w91&peers1) " & _ ") = 8 " & _ "limit 1 " & _ ") " & _ ", " & _ "( " & _ "select i " & _ "from ( " & _ "select i, " & _ "max ( " & _ "(w10&peers0 or w11&peers1) + " & _ "(w20&peers0 or w21&peers1) + " & _ "(w30&peers0 or w31&peers1) + " & _ "(w40&peers0 or w41&peers1) + " & _ "(w50&peers0 or w51&peers1) + " & _ "(w60&peers0 or w61&peers1) + " & _ "(w70&peers0 or w71&peers1) + " & _ "(w80&peers0 or w81&peers1) + " & _ "(w90&peers0 or w91&peers1) " & _ ") as maxfixed " & _ "from i " & _ "where not (word0&w0 or word1&w1) " & _ ") " & _ "where maxfixed is not null " & _ ")) " & _ "join z " & _ "on " & _ "case z " & _ "when 1 then not (w10&peers0 or w11&peers1) " & _ "when 2 then not (w20&peers0 or w21&peers1) " & _ "when 3 then not (w30&peers0 or w31&peers1) " & _ "when 4 then not (w40&peers0 or w41&peers1) " & _ "when 5 then not (w50&peers0 or w51&peers1) " & _ "when 6 then not (w60&peers0 or w61&peers1) " & _ "when 7 then not (w70&peers0 or w71&peers1) " & _ "when 8 then not (w80&peers0 or w81&peers1) " & _ "when 9 then not (w90&peers0 or w91&peers1) " & _ "end " & _ "order by fixed desc, " & _ "zfixed desc " & _ ") " & _ ", " & _ "output as ( " & _ "select * " & _ "from ( " & _ "select 1 as i, " & _ "w10, w11, " & _ "w20, w21, " & _ "w30, w31, " & _ "w40, w41, " & _ "w50, w51, " & _ "w60, w61, " & _ "w70, w71, " & _ "w80, w81, " & _ "w90, w91, " & _ "'' as sud " & _ "from sudoku " & _ "where fixed = 81 limit 1 " & _ ") " & _ "union all " & _ "select nullif (output.i + 1, 82), " & _ "w10, w11, " & _ "w20, w21, " & _ "w30, w31, " & _ "w40, w41, " & _ "w50, w51, " & _ "w60, w61, " & _ "w70, w71, " & _ "w80, w81, " & _ "w90, w91, " & _ "sud || replace (cast ( " & _ "case 1 " & _ "when w10&word0 OR w11&word1 then 1 " & _ "when w20&word0 OR w21&word1 then 2 " & _ "when w30&word0 OR w31&word1 then 3 " & _ "when w40&word0 OR w41&word1 then 4 " & _ "when w50&word0 OR w51&word1 then 5 " & _ "when w60&word0 OR w61&word1 then 6 " & _ "when w70&word0 OR w71&word1 then 7 " & _ "when w80&word0 OR w81&word1 then 8 " & _ "when w90&word0 OR w91&word1 then 9 " & _ "else 0 " & _ "end " & _ "as char), '0', ' ') " & _ "from output " & _ "join i on i.i = output.i " & _ ") " & _ ", " & _ "result as (select sud s from input union all select sud from output WHERE i is null) " & _ "SELECT " & _ "'┏━━━┯━━━┯━━━┳━━━┯━━━┯━━━┳━━━┯━━━┯━━━┓' || x'0d0a' || " & _ "'┃ ' || substr(s, 1,1) || ' │ ' || substr(s, 2,1) || ' │ ' || substr(s, 3,1) || ' ┃ ' || " & _ "substr(s, 4,1) || ' │ ' || substr(s, 5,1) || ' │ ' || substr(s, 6,1) || ' ┃ ' || " & _ "substr(s, 7,1) || ' │ ' || substr(s, 8,1) || ' │ ' || substr(s, 9,1) || ' ┃' || x'0d0a' || " & _ "'┠───┼───┼───╂───┼───┼───╂───┼───┼───┨' || x'0d0a' || " & _ "'┃ ' || substr(s,10,1) || ' │ ' || substr(s,11,1) || ' │ ' || substr(s,12,1) || ' ┃ ' || " & _ "substr(s,13,1) || ' │ ' || substr(s,14,1) || ' │ ' || substr(s,15,1) || ' ┃ ' || " & _ "substr(s,16,1) || ' │ ' || substr(s,17,1) || ' │ ' || substr(s,18,1) || ' ┃' || x'0d0a' || " & _ "'┠───┼───┼───╂───┼───┼───╂───┼───┼───┨' || x'0d0a' || " & _ "'┃ ' || substr(s,19,1) || ' │ ' || substr(s,20,1) || ' │ ' || substr(s,21,1) || ' ┃ ' || " & _ "substr(s,22,1) || ' │ ' || substr(s,23,1) || ' │ ' || substr(s,24,1) || ' ┃ ' || " & _ "substr(s,25,1) || ' │ ' || substr(s,26,1) || ' │ ' || substr(s,27,1) || ' ┃' || x'0d0a' || " & _ "'┣━━━┿━━━┿━━━╋━━━┿━━━┿━━━╋━━━┿━━━┿━━━┫' || x'0d0a' || " & _ "'┃ ' || substr(s,28,1) || ' │ ' || substr(s,29,1) || ' │ ' || substr(s,30,1) || ' ┃ ' || " & _ "substr(s,31,1) || ' │ ' || substr(s,32,1) || ' │ ' || substr(s,33,1) || ' ┃ ' || " & _ "substr(s,34,1) || ' │ ' || substr(s,35,1) || ' │ ' || substr(s,36,1) || ' ┃' || x'0d0a' || " & _ "'┠───┼───┼───╂───┼───┼───╂───┼───┼───┨' || x'0d0a' || " & _ "'┃ ' || substr(s,37,1) || ' │ ' || substr(s,38,1) || ' │ ' || substr(s,39,1) || ' ┃ ' || " & _ "substr(s,40,1) || ' │ ' || substr(s,41,1) || ' │ ' || substr(s,42,1) || ' ┃ ' || " & _ "substr(s,43,1) || ' │ ' || substr(s,44,1) || ' │ ' || substr(s,45,1) || ' ┃' || x'0d0a' || " & _ "'┠───┼───┼───╂───┼───┼───╂───┼───┼───┨' || x'0d0a' || " & _ "'┃ ' || substr(s,46,1) || ' │ ' || substr(s,47,1) || ' │ ' || substr(s,48,1) || ' ┃ ' || " & _ "substr(s,49,1) || ' │ ' || substr(s,50,1) || ' │ ' || substr(s,51,1) || ' ┃ ' || " & _ "substr(s,52,1) || ' │ ' || substr(s,53,1) || ' │ ' || substr(s,54,1) || ' ┃' || x'0d0a' || " & _ "'┣━━━┿━━━┿━━━╋━━━┿━━━┿━━━╋━━━┿━━━┿━━━┫' || x'0d0a' || " & _ "'┃ ' || substr(s,55,1) || ' │ ' || substr(s,56,1) || ' │ ' || substr(s,57,1) || ' ┃ ' || " & _ "substr(s,58,1) || ' │ ' || substr(s,59,1) || ' │ ' || substr(s,60,1) || ' ┃ ' || " & _ "substr(s,61,1) || ' │ ' || substr(s,62,1) || ' │ ' || substr(s,63,1) || ' ┃' || x'0d0a' || " & _ "'┠───┼───┼───╂───┼───┼───╂───┼───┼───┨' || x'0d0a' || " & _ "'┃ ' || substr(s,64,1) || ' │ ' || substr(s,65,1) || ' │ ' || substr(s,66,1) || ' ┃ ' || " & _ "substr(s,67,1) || ' │ ' || substr(s,68,1) || ' │ ' || substr(s,69,1) || ' ┃ ' || " & _ "substr(s,70,1) || ' │ ' || substr(s,71,1) || ' │ ' || substr(s,72,1) || ' ┃' || x'0d0a' || " & _ "'┠───┼───┼───╂───┼───┼───╂───┼───┼───┨' || x'0d0a' || " & _ "'┃ ' || substr(s,73,1) || ' │ ' || substr(s,74,1) || ' │ ' || substr(s,75,1) || ' ┃ ' || " & _ "substr(s,76,1) || ' │ ' || substr(s,77,1) || ' │ ' || substr(s,78,1) || ' ┃ ' || " & _ "substr(s,79,1) || ' │ ' || substr(s,80,1) || ' │ ' || substr(s,81,1) || ' ┃' || x'0d0a' || " & _ "'┗━━━┷━━━┷━━━┻━━━┷━━━┷━━━┻━━━┷━━━┷━━━┛'" & _ "FROM result;" Local $aRows, $iRows, $iCols Local $sProblem Local $iTime For $n = 0 To UBound($aSudokus) - 1 $iTime = TimerInit() $sProblem = StringReplace($sInsaneSolver, "#####", $aSudokus[$n][0]) _SQLite_GetTable($hDB, $sProblem, $aRows,$iRows, $iCols) _ConsoleWrite($aSudokus[$n][0] & " problem" & @LF & $aRows[2] & @LF & @LF) _ConsoleWrite($aSudokus[$n][0] & " solution (" & Round(TimerDiff($iTime) / 1000, 3) & " s)" & @LF & $aRows[3] & @LF & @LF) Next Func _ConsoleWrite($s) ConsoleWrite(BinaryToString(StringToBinary($s, 4), 1)) EndFunc