Leaderboard
Popular Content
Showing content with the highest reputation on 01/06/2018 in all areas
-
that sad because its take less then 5 sec with backtracking algorithm built in autoit SudokuSolver.au32 points
-
Fast Sudoku solver (insane) in pure SQL[ite]
argumentum reacted to Gianni for a topic
it's probably because the first part of the query still looks for all the results spending all the needed time, and then the second part just picks up only the wanted results1 point -
Fast Sudoku solver (insane) in pure SQL[ite]
argumentum reacted to Gianni for a topic
Sorry, but you're right! doing some previous tests I modified and saved the query by inserting the clause "LIMIT 3;" at the end of the query, then I forgot about this change I had made and continued to use the modified query getting results limited to 3. my fault! sorry. P.S.....I'm getting old1 point -
Fast Sudoku solver (insane) in pure SQL[ite]
Gianni reacted to argumentum for a topic
no clue, I've added the code I'm using to my post above. 37...8........32..1......6..9.12.5....4...1....1.37.2..2......9..69........2...18 372568491689413275145792863798124536234659187561837924427381659816975342953246718 372568491689413275145792863897124536234659187561837924428371659716985342953246718 372568491968413275145792863793124586284659137651837924427381659816975342539246718 372618495568493271149752863793124586254869137681537924427381659816975342935246718 372618495568493271149752863793124586284569137651837924427381659816975342935246718 372618495648593271159742863793126584264859137581437926427381659816975342935264718 372618495658493271149752863793124586284569137561837924427381659816975342935246718 372618495685493271149752863798124536234569187561837924427381659816975342953246718 372618495685493271149752863897124536234569187561837924428371659716985342953246718 372618495689453271145792863798124536234569187561837924427381659816975342953246718 372618495689453271145792863897124536234569187561837924428371659716985342953246718 372618495968453271145792863793124586254869137681537924427381659816975342539246718 372618495968453271145792863793124586284569137651837924427381659816975342539246718 372658491689413275145792863798124536234569187561837924427381659816975342953246718 372658491689413275145792863897124536234569187561837924428371659716985342953246718 372658491968413275145792863793124586254869137681537924427381659816975342539246718 372658491968413275145792863793124586284569137651837924427381659816975342539246718 PS: added my array above PS2: using _SQLite_LibVersion = 3.20.0 PS3: the ".....7.9..3..2...8..96..5....53..9...1..8...26....4...3......1..4......7..7...3.." result is below: PS4: I just read your post below. this happens to the best of us1 point -
BBs19, Do you mind if I'm copying all your code, reuse as much as I find useful, and continues the project as a new example. You'll of course get full credit for your part of the code. I see no reason why such a project cannot be implemented in AutoIt.1 point
-
GUIListViewEx - BugFix Version 6 Apr 24
Earthshine reacted to Melba23 for a topic
Biatu, Quite possibly, but I have no intention of adding such a functionality to this UDF. Why not just react when the item is double-clicked? M231 point -
Access Excel file in sharepoint
Earthshine reacted to water for a topic
Dannydy has been offline for more than 4 1/2 years. Don't hold your breath for an answer IIRC users have created a few topics regarding SharePoint and Excel in th meantime.1 point -
The Excel part can be solved with the Excel UDF that comes with AutoIt. See functions _Excel_RangeRead and _Excel_Rangewrite.1 point
-
Fast Sudoku solver (insane) in pure SQL[ite]
argumentum reacted to farouk12 for a topic
Well its not mine i got it from topic here (I dont know the link / Author). And thanks for the edit, now its good as example. I found out that back tracking is more effective in some situations, rather than the sql way.(Big deference)1 point -
Extract input to an Excel file
KickStarter15 reacted to benners for a topic
Well. been playing all day and have come up with this. It just draws the gui and sets up the control arrays for later. One annoying problem to sort out when drawing the controls,. It will only create the same amount of controls as there are cells with text in the excel file. This way redundant controls aren't added #include <Array.au3> #include <ColorConstants.au3> #include <EditConstants.au3> #include <Excel.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <GUIScrollbars_Ex.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "CloseProgram") ; create the arrays to hold the controlIDs for the tab guis. These can be referenced ; later when writing their values to the excel sheet Global _ $aid_FrontMatterGUI = '', _ $aid_BodyMatterGUI = '', _ $aid_BackMatterGUI = '' ; theee are integers that relate to where the controliDs are located in $g_aidControls. ; The control ID can be retrieved like so, $g_aidControls[$EMPPROCESS_INP] Global Enum _ $FRONTMATTERGUI, _ $BODYMATTERGUI, _ $BACKMATTERGUI, _ $EMPNUMBER_INP, _ $EMPNAME_INP, _ $EMPPROCESS_INP, _ $MYSTERY_LBL, _ $AGREE_CHK, _ $ACCEPT_CHK, _ $REJECT_CHK, _ $SUBMIT_BTN, _ $MAIN_TAB, _ $ARRAYMAX ; create the array to hold the remaining controlIDs. These can be referenced ; later when writing their values to the excel sheet Global $g_aidControls[$ARRAYMAX] ; set the path to the file that has the values for the inputs Global $g_sExcelFile = @ScriptDir & "\Sample.xlsx" Draw_GUI() ;~ _ArrayDisplay($g_aidControls) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(50) WEnd Func CloseProgram() Exit EndFunc ;==>CloseProgram Func CreateTabGUIs(ByRef $as_RangeRead, $i_ArrayRow, $h_MainGUI) ; create the gui for the controls and add it to the global controls array $g_aidControls[$i_ArrayRow] = GUICreate("", 770, 420, 12, 220, $WS_POPUP, $WS_EX_MDICHILD, $h_MainGUI) GUISetBkColor($COLOR_WHITE) Local $i_Columns = 5 ; create the temp array Local $aid_Temp[61][$i_Columns] = [[60]] ; Create the controls GUICtrlCreateLabel("ENTRY(S)", 50, 20, 80, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel("N/A", 212, 20, 40, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel("NO ERROR", 291, 20, 70, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel("WITH ERROR", 383, 20, 85, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel("REMARKS", 570, 20, 90, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) Local $s_Value = '' Local _ $i_ArrayRows = 0, _ $i_Left = 0, _ $i_Rows = 60, _ $i_Spacing = 60, _ $i_Top = 0 For $i = 1 To $aid_Temp[0][0] ; 1 to 60 rows of controls ; get the value to add to the control $s_Value = $as_RangeRead[$i - 1][$i_ArrayRow] ; don't create anymore controls if the value is blanks ; ### comment this line and it will create empty controls on the gui ### ; ### and for some reason a blank one at the top which I can't figure out why ### ; ### if you use $i as the value it is always the last one such as 60 of 60 but it is the first input GRRRRRRR #### If Not $s_Value Then ExitLoop ; calculate additional spacing $i_Left = (Int($i / $i_Rows)) $i_Top = (30.7 * Mod($i, $i_Rows)) ; draw the inputs and add the controlID to the correct gui array $aid_Temp[$i][0] = GUICtrlCreateInput("", ($i_Spacing - 50) + $i_Left, $i_Top + $i_Spacing, 155, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetData(-1, $s_Value) ; draw the N/A check boces $aid_Temp[$i][1] = GUICtrlCreateCheckbox("", ($i_Spacing + 165) + $i_Left, $i_Top + $i_Spacing, 15, 20) ; draw the no error $aid_Temp[$i][2] = GUICtrlCreateCheckbox("", ($i_Spacing + 260) + $i_Left, $i_Top + $i_Spacing, 15, 20) ; draw the with error check boxes $aid_Temp[$i][3] = GUICtrlCreateCheckbox("", ($i_Spacing + 355) + $i_Left, $i_Top + $i_Spacing, 15, 20) ; draw the edit boxes $aid_Temp[$i][4] = GUICtrlCreateEdit("", ($i_Spacing + 440) + $i_Left, $i_Top + $i_Spacing, 240, 24, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN)) $i_ArrayRows += 1 Next ; add scroll bars to the current gui _GUIScrollbars_Generate($g_aidControls[$i_ArrayRow], 0, 2000) $aid_Temp[0][0] = $i_ArrayRows ; update the total number of controls ;~ Redim $aid_Temp[$i_ArrayRows + 1][$i_Columns] ; redim the array. not really needed but nice to do Return $aid_Temp EndFunc ;==>CreateTabGUIs Func Draw_GUI() Local $h_MainGUI = GUICreate("Test Form", 820, 740, -1, -1) GUISetBkColor(0x38A7D2) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseProgram") GUICtrlCreatePic(@ScriptDir & "\Image.jpg", 690, 15, 120, 120) GUICtrlCreateLabel("Welcome: " & GetFullName(@UserName), 17, 130, 500, 16) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetFont(-1, 9, $FW_BOLD) #Region #### Main Menu ########################### Local $id_Menu = GUICtrlCreateMenu("File") GUICtrlCreateMenuItem("Close", $id_Menu) GUICtrlSetOnEvent(-1, 'CloseProgram') GUICtrlCreateMenuItem("Export", $id_Menu) GUICtrlSetOnEvent(-1, 'MainMenu_FileExport') $id_Menu = GUICtrlCreateMenu("Edit") GUICtrlSetState(-1, $GUI_Disable) $id_Menu = GUICtrlCreateMenu("Option") GUICtrlSetState(-1, $GUI_Disable) $id_Menu = GUICtrlCreateMenu("View") GUICtrlCreateMenuItem("Exit", $id_Menu) GUICtrlSetState(-1, $GUI_Disable) GUICtrlSetOnEvent(-1, 'MainMenu_ViewExit') $id_Menu = GUICtrlCreateMenu("Help") GUICtrlCreateMenuItem("About", $id_Menu) GUICtrlSetOnEvent(-1, 'MainMenu_HelpAbout') #EndRegion #### Main Menu ########################### #Region #### Employee Info ####################### GUICtrlCreateGroup("Employee Information", 16, 8, 281, 121) GUICtrlCreateLabel("Emp#:", 33, 35, 35, 17) $g_aidControls[$EMPNUMBER_INP] = GUICtrlCreateInput("1234567", 72, 32, 217, 21) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Name:", 33, 59, 35, 17) $g_aidControls[$EMPNAME_INP] = GUICtrlCreateInput(GetFullName(@UserName), 72, 56, 217, 21) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Process:", 24, 83, 45, 17) $g_aidControls[$EMPPROCESS_INP] = GUICtrlCreateInput("First Process", 72, 80, 217, 21) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion #### Employee Info ####################### #Region #### whatever this is #################### GUICtrlCreateLabel("AID:", 10, 170, 25, 17) GUICtrlSetFont(-1, 10, $FW_BOLD) $g_aidControls[$MYSTERY_LBL] = GUICtrlCreateLabel("ABZ123456", 40, 170, 90, 17) ; remove this if you don't alter the text GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetFont(-1, 10, $FW_BOLD) #EndRegion #### whatever this is #################### #Region #### confirmation checkboxes ############# $g_aidControls[$AGREE_CHK] = GUICtrlCreateCheckbox("I agree that I have checked the entry(s) above.", 16, 659, 265, 17) $g_aidControls[$ACCEPT_CHK] = GUICtrlCreateCheckbox("Accept", 16, 677, 50, 17) GUICtrlCreateLabel("*", 72, 680, 40, 17) GUICtrlSetColor(-1, $COLOR_RED) GUICtrlSetFont(-1, 10, $FW_BOLD) $g_aidControls[$REJECT_CHK] = GUICtrlCreateCheckbox("Reject", 16, 695, 50, 17) GUICtrlCreateLabel("*", 70, 695, 40, 17) GUICtrlSetColor(-1, $COLOR_RED) GUICtrlSetFont(-1, 10, $FW_BOLD) #EndRegion #### confirmation checkboxes ############# #Region #### submit button ########################### $g_aidControls[$SUBMIT_BTN] = GUICtrlCreateButton("Submit Report", 635, 672, 177, 33) GUICtrlSetOnEvent(-1, "Submit") #EndRegion #### submit button ########################### #Region #### Create Tabs ######################### Draw_Tabs($h_MainGUI) #EndRegion #### Create Tabs ######################### GUISetState(@SW_SHOW, $h_MainGUI) ; show the main gui Sleep(80) ; add a sleep to try and get them to show at the same time GUISetState(@SW_SHOW, $g_aidControls[$FRONTMATTERGUI]) ; show the first tab gui EndFunc ;==>Draw_GUI Func Draw_Tabs($h_MainGUI) ; create the main tab control $g_aidControls[$MAIN_TAB] = GUICtrlCreateTab(10, 190, 780, 455, $WS_EX_MDICHILD) GUICtrlSetOnEvent(-1, "TabChange") ; do summat on tab change ; create the child tab item GUICtrlCreateTabItem("Front Matter") GUICtrlCreateTabItem("Body Matter") GUICtrlCreateTabItem("Back Matter") GUICtrlCreateTabItem("") ; get the strings that will populate the gui inputs from the excel sheet ; ### add some error checking for this #### Local $as_RangeRead = Excel_GetValuesFromRange() ; loop though the array of arrays For $i = 1 To 3 ; create the 3 tabs, gui and their controls Switch $i Case 1 $aid_FrontMatterGUI = CreateTabGUIs($as_RangeRead, $i - 1, $h_MainGUI) Case 2 $aid_BodyMatterGUI = CreateTabGUIs($as_RangeRead, $i - 1, $h_MainGUI) Case 3 $aid_BackMatterGUI = CreateTabGUIs($as_RangeRead, $i - 1, $h_MainGUI) EndSwitch Next ;~ _ArrayDisplay($aid_FrontMatterGUI) ;~ _ArrayDisplay($aid_BodyMatterGUI) ;~ _ArrayDisplay($aid_BackMatterGUI) EndFunc ;==>Draw_Tabs Func Excel_GetValuesFromRange() ; ### add some error checking to this function Local $o_Excel = _Excel_Open(False) Local $o_Workbook = _Excel_BookOpen($o_Excel, $g_sExcelFile) Local $as_RangeRead = _Excel_RangeRead($o_Workbook, Default, $o_Workbook.ActiveSheet.Usedrange.Columns("A:C"), 2) _Excel_Close($o_Excel) Return $as_RangeRead EndFunc ;==>Excel_GetValuesFromRange Func GetFullName($sUserName) ; I can't test this ;~ $strComputer = "localhost" ; do you need to specify this???? ;~ Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name = '" & $sUserName & "'", "WQL", 0x10 + 0x20) If Not IsObj($colItems) Then Return SetError(1, 0, "") For $objItem In $colItems Return $objItem.FullName Next EndFunc ;==>GetFullName Func MainMenu_FileExport() ; add commands later EndFunc ;==>MainMenu_FileExport Func MainMenu_HelpAbout() ; add commands later EndFunc ;==>MainMenu_HelpAbout Func MainMenu_ViewExit() ; add commands later EndFunc ;==>MainMenu_ViewExit Func TabChange() Switch GUICtrlRead($g_aidControls[$MAIN_TAB]) Case 0 ; Front Matter tab GUISetState(@SW_SHOW, $g_aidControls[$FRONTMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BODYMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BACKMATTERGUI]) Case 1 ; body Matter tab GUISetState(@SW_HIDE, $g_aidControls[$FRONTMATTERGUI]) GUISetState(@SW_SHOW, $g_aidControls[$BODYMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BACKMATTERGUI]) Case 2 ; back matter tab GUISetState(@SW_HIDE, $g_aidControls[$FRONTMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BODYMATTERGUI]) GUISetState(@SW_SHOW, $g_aidControls[$BACKMATTERGUI]) EndSwitch EndFunc ;==>TabChange Func Submit() ; ##### left this as I don't know whether you right all the 3 guis control values or just the current one #### ;~ Local $o_Excel = _Excel_Open(False) ;~ Local $o_Workbook = _Excel_BookOpen($o_Excel, $g_sExcelFile) ;~ If @error Then Return SetError(1) ;~ Local $ai_Labels[4] = [3, $id_EmpNbr_inp, $id_EmpNme_inp, $id_EmpPrs_inp] ;~ For $i = 1 To $ai_Labels[0] ;~ _Excel_RangeWrite($o_Workbook, Default, GUICtrlRead($ai_Labels[$i]), "D" & $i) ;~ Next ;~ _Excel_Close($o_Excel) ;~ ShellExecute($g_sExcelFile) EndFunc ;==>Submit I have attached the sample file as the one in the first post had a blank cell before GTOC. Sample.xlsx1 point -
As stated before, im planning on rewriting the UDF to throw out all the unnecessary trash that makes adding new things and fixing problems too difficult. It started out as a simple script for modern buttons with hover effects and grew over time into a huge mess. However this UDF is currently not on my prio list and I am not sure when I will have the time to finish it. As @Earthshine stated, there are better solutions for modern apps. Creating everything from scratch is just too time consuming. Another project I started ended up in a mess with hundreds of workarounds where I spend days trying to make basic things work and all of it just to get a "modern" looking app. It worked out eventually but so much time was wasted that I could have just used to learn other languages AutoIt seems a bit dead to me, just look at the time it was last updated, no more updates, no new features, no multitasking. ..1 point
-
So you seriously think we create a function to display a JPG in a gui and then deliberately fuck it up by making a part black? Jos1 point
-
Fast Sudoku solver (insane) in pure SQL[ite]
Earthshine reacted to farouk12 for a topic
You will find the answer in this pdf (With all Information about making Sudoku) . Sudoku.pdf1 point -
Extract input to an Excel file
KickStarter15 reacted to benners for a topic
You create the create the checkboxes in an array but the array is overwritten each time you build the tab so there are no IDs for the controls. If there were you could loop through them and get the values as I did in the submit button. There's no need to rebuild the controls when you change tabs, as far as I can see, so you could just have a 2D array with enough rows for the controls and enough columns for the number of tabs. The other thing is if the report is going to be read by humans or is just for saving. If it's going to be read by humans then you will have to change the values you get from reading the checkboxes to values that everyone knows, such as with checkboxes. They return 1, 2 or 4. If you saw that in the report you wouldn't know what it meant Does it need to be recorded as yes/no , for instance with the I agree\accept or reject boxes?. Before going any further I would look at streamlining the code to improve it and increase the speed and make it easier to add your values to the excel sheet. There are a lot of repeated actions that could be made into functions and variables created (when controls are added) that don't need to be. Normally, if I am not going to reference or change the controls value, such as a labels text, I don't assign it a variable. I would also use a variable naming convention, such as the one listed here I'll have a play with the code if you want and give you some examples and people cleverer than I can improve it1 point -
Fast Sudoku solver (insane) in pure SQL[ite]
argumentum reacted to Gianni for a topic
I've done a very little modification. Changed only few lines to generate a new random puzzle on each run (don't know if it's an hard or simple puzle) also changed the output so to be in plain ascii chars #include <SQLite.au3> ;~ #include <SQLite.dll.au3> ; download the most recent suitable DLL once and comment this out ; save the sqlite3.dll along with this script Local $hDB _SQLite_Startup() ; _SQLite_Startup('.\sqlite3.dll") $hDB = _SQLite_Open() ; an empty puzzle Local $aSudokus[1][2] = [["Random", " "]] Local $aRows, $iRows, $iCols Local $sProblem ; generate a sequence of numbers 1 to 9 in a random order using an SQL query Local $aRandom, $sSQL_Query = "WITH RECURSIVE cnt(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM cnt LIMIT 9) SELECT x FROM cnt ORDER BY random();" _SQLite_GetTable(-1, $sSQL_Query, $aRandom, $iRows, $iCols) ; generate a random sudoku puzzle For $i = 0 To 8 $aSudokus[0][1] = StringReplace($aSudokus[0][1], $i * 9 + Random(1,9,1) , $aRandom[$i + 2], 1) Next 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<<ibit else 0 end AS word0, " & _ "case when iword=1 then 1<<ibit else 0 end AS word1, " & _ "CASE WHEN iword=0 THEN (512-1)<<(y*9) ELSE 0 END | " & _ "((1+512*(1+512*(1+512*(1+512*(1+512)))))<<x) | " & _ "CASE WHEN iword=0 THEN ((8-1)*(1+512*(1+512)))<<(y/3*3*9+x/3*3) ELSE 0 END AS peers0, " & _ "CASE WHEN iword=1 THEN (512-1)<<((y%6)*9) ELSE 0 END | " & _ "((1 + 512 * (1 + 512)) << x) | " & _ "CASE WHEN iword=1 THEN ((8-1)*(1+512*(1+512)))<<((y%6)/3*3*9+x/3*3) ELSE 0 END AS peers1 " & _ "from (" & _ "with xy AS (SELECT 0 AS xy UNION ALL SELECT xy+1 FROM xy WHERE xy < 80) " & _ "select xy+1 AS i, " & _ "xy%9 AS x, " & _ "xy/9 AS y, " & _ "xy/54 AS iword, " & _ "xy%54 AS ibit " & _ "from xy" & _ ")" & _ ";" _SQLite_Exec($hDB, $sTempCreate) Local $sInsaneSolver = "" & _ "with z AS (SELECT 1 AS z UNION ALL SELECT z+1 FROM z WHERE z < 9), " & _ "input as (" & _ "select input, " & _ "sud, " & _ "ifnull (sum (word0), 0) as w0, " & _ "ifnull (sum (word1), 0) as w1, " & _ "ifnull (sum (case when z=1 then word0 end), 0) as w10, " & _ "ifnull (sum (case when z=1 then word1 end), 0) as w11, " & _ "ifnull (sum (case when z=2 then word0 end), 0) as w20, " & _ "ifnull (sum (case when z=2 then word1 end), 0) as w21, " & _ "ifnull (sum (case when z=3 then word0 end), 0) as w30, " & _ "ifnull (sum (case when z=3 then word1 end), 0) as w31, " & _ "ifnull (sum (case when z=4 then word0 end), 0) as w40, " & _ "ifnull (sum (case when z=4 then word1 end), 0) as w41, " & _ "ifnull (sum (case when z=5 then word0 end), 0) as w50, " & _ "ifnull (sum (case when z=5 then word1 end), 0) as w51, " & _ "ifnull (sum (case when z=6 then word0 end), 0) as w60, " & _ "ifnull (sum (case when z=6 then word1 end), 0) as w61, " & _ "ifnull (sum (case when z=7 then word0 end), 0) as w70, " & _ "ifnull (sum (case when z=7 then word1 end), 0) as w71, " & _ "ifnull (sum (case when z=8 then word0 end), 0) as w80, " & _ "ifnull (sum (case when z=8 then word1 end), 0) as w81, " & _ "ifnull (sum (case when z=9 then word0 end), 0) as w90, " & _ "ifnull (sum (case when z=9 then word1 end), 0) as w91, " & _ "count (*) as fixed, " & _ "ifnull (sum (z=1), 0) as f1, " & _ "ifnull (sum (z=2), 0) as f2, " & _ "ifnull (sum (z=3), 0) as f3, " & _ "ifnull (sum (z=4), 0) as f4, " & _ "ifnull (sum (z=5), 0) as f5, " & _ "ifnull (sum (z=6), 0) as f6, " & _ "ifnull (sum (z=7), 0) as f7, " & _ "ifnull (sum (z=8), 0) as f8, " & _ "ifnull (sum (z=9), 0) as f9 " & _ "from ( " & _ "select '" & $aSudokus[0][0] & "' as input, " & _ "'" & $aSudokus[0][1] & "' as sud " & _ ") " & _ "join i " & _ "join z on z = cast (substr (sud, i.i, 1) as int) " & _ "where input='#####' " & _ ") " & _ ", " & _ "sudoku as (" & _ "select " & _ "'' as text, " & _ "fixed, " & _ "f1,f2,f3,f4,f5,f6,f7,f8,f9, " & _ "0 as zfixed, " & _ "0 as i0, " & _ "w0, w1, " & _ "w10, w11, " & _ "w20, w21, " & _ "w30, w31, " & _ "w40, w41, " & _ "w50, w51, " & _ "w60, w61, " & _ "w70, w71, " & _ "w80, w81, " & _ "w90, w91 " & _ "from input " & _ "union all " & _ "select " & _ "(fixed+1)||','|| " & _ "name||','|| " & _ "( " & _ "(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) " & _ ") ||','|| " & _ "z||','|| " & _ "'', " & _ "fixed+1, " & _ "f1+(z=1), " & _ "f2+(z=2), " & _ "f3+(z=3), " & _ "f4+(z=4), " & _ "f5+(z=5), " & _ "f6+(z=6), " & _ "f7+(z=7), " & _ "f8+(z=8), " & _ "f9+(z=9), " & _ "case z " & _ "when 1 then f1 " & _ "when 2 then f2 " & _ "when 3 then f3 " & _ "when 4 then f4 " & _ "when 5 then f5 " & _ "when 6 then f6 " & _ "when 7 then f7 " & _ "when 8 then f8 " & _ "when 9 then f9 " & _ "end, " & _ "i.i, " & _ "w0+word0, " & _ "w1+word1, " & _ "case when z=1 then w10+word0 else w10 end, " & _ "case when z=1 then w11+word1 else w11 end, " & _ "case when z=2 then w20+word0 else w20 end, " & _ "case when z=2 then w21+word1 else w21 end, " & _ "case when z=3 then w30+word0 else w30 end, " & _ "case when z=3 then w31+word1 else w31 end, " & _ "case when z=4 then w40+word0 else w40 end, " & _ "case when z=4 then w41+word1 else w41 end, " & _ "case when z=5 then w50+word0 else w50 end, " & _ "case when z=5 then w51+word1 else w51 end, " & _ "case when z=6 then w60+word0 else w60 end, " & _ "case when z=6 then w61+word1 else w61 end, " & _ "case when z=7 then w70+word0 else w70 end, " & _ "case when z=7 then w71+word1 else w71 end, " & _ "case when z=8 then w80+word0 else w80 end, " & _ "case when z=8 then w81+word1 else w81 end, " & _ "case when z=9 then w90+word0 else w90 end, " & _ "case when z=9 then w91+word1 else w91 end " & _ "from sudoku " & _ "join i " & _ "on i = ifnull ( " & _ "( " & _ "select i " & _ "from i " & _ "where i > 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;" For $n = 0 To UBound($aSudokus) - 1 $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" & @LF & $aRows[3] & @LF & @LF) Next Func _ConsoleWrite($s) ;ConsoleWrite(BinaryToString(StringToBinary($s, 4), 1)) ConsoleWrite($s) EndFunc1 point -
New Java Binding of AutoIt
CosmicDan reacted to AndrewDavison for a topic
Sorry, I am unable to read your comment because the text is too small Perhaps you could try this link: http://www.wikihow.com/Change-the-Font-Size-in-a-Browser1 point -
Have you learned to see this post is over 5 YEARS OLD?1 point
-
rebol? Never heard, and to be honest I don't care, as this is the AutoIT forum! If you need speed, the program in C,C++ or even better in Assembly! BTW: I applied some optimization techniques to your code. Actually I converted the code to C, then I compiled it with maximum optimization enabled and told the compiler to generate assembly code. By using a "reverse" compiler I generated C code from the optimized assembly code, which I then converted back to AutoIT. Here is the result. It does exactly the same as your code and takes only 0.00000530793718196028 seconds to run. Now, beat THAT with rebol!!! $begin = TimerInit() $i=100000000 ; <== OPTIMIZED VERSION OF YOUR CODE !! $dif = TimerDiff($begin)/1000 MsgBox(1,"",$dif)1 point