Всем добрый день!
Решил сделать програмку-генератор существующих (по словарю) слов из букв заданного слова.
Программа работает но очень медленно (словарь слишком большой).
Помогите оптимазировать для ускорения работы программы.
В прикрепленном файле находится словарь.
Решил сделать програмку-генератор существующих (по словарю) слов из букв заданного слова.
Программа работает но очень медленно (словарь слишком большой).
Помогите оптимазировать для ускорения работы программы.
В прикрепленном файле находится словарь.
Код:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=document.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
;
Global $iClicked = 0, $iDoubleClicked = 0
$p = 0
$No = False
$Yes = False
$answer = InputBox("Слово - пример", "Введите слово для генерации", "тиранозавр")
$answer2 = $answer
$len = StringLen($answer)
$x = -15
$y = 10
$poisc = True
$poisc2 = 0
$NoSek = 1
$key = 0
Dim $a = "абвгдеёжзийклмнопрстуфхцчшщэюя"
Dim $Next = 1
Dim $Next2 = 0
Dim $VsegoSlov = 0
Dim $NomerTexta = 3
Dim $NTsection[5000]
Dim $NTkey[5000]
Dim $xx[5000]
Dim $yy[5000]
Dim $delini = False
Dim $delini2 = 0
Dim $baza = 0
;Dim $f($x) = ""
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Генерация слов -> " & $answer, 847, 710, 192, 124)
GUICtrlCreateLabel ("", 10, 10, 50, 15)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
If $delini = True Then
$label1 = GUICtrlCreateLabel("Обновление базы... " & $baza & " %", 170, 232, 700, 41)
GUICtrlSetFont(-1, 25, 800, 0, "MS Sans Serif")
For $a2 = 1 To 30
$PerwayaBuk = StringMid($a, $a2, 1)
$poisc2 = StringInStr($answer, $PerwayaBuk)
If $poisc2 > 0 Then
For $b2 = 1 To 9
$baza = $baza + 0.37037
GUICtrlSetData($label1, "Обновление базы... " & Round($baza, 2) & " %")
$ii = 0
While 1
$ii=$ii+1
$tt = IniRead("AllWords.ini", "WordLen_" & $a2 & "_" & $b2, $ii, "NotFound")
If $tt = "NotFound" Then ExitLoop
If $tt = "-----" Then
$tt2 = IniRead("AllWords.ini", "WordLen_" & $a2 & "_" & $b2, ($ii + 1), "NotFound")
If $tt2 = "NotFound" Then
IniDelete("AllWords.ini", "WordLen_" & $a2 & "_" & $b2, $ii)
$delini2 = $delini2 - 1
Else
IniWrite("AllWords.ini", "WordLen_" & $a2 & "_" & $b2, $ii, $tt2)
IniWrite("AllWords.ini", "WordLen_" & $a2 & "_" & $b2, $ii + 1, "-----")
EndIf
EndIf
If $delini2 = 0 Then ExitLoop
WEnd
If $delini2 = 0 Then ExitLoop
Next
If $delini2 = 0 Then ExitLoop
Else
$baza = $baza + (0.37037 * 9)
GUICtrlSetData($label1, "Обновление базы... " & Round($baza, 2) & " %")
EndIf
Next
EndIf
Exit
EndSwitch
If $iDoubleClicked > 0 Then
$iID = $iDoubleClicked
$iDoubleClicked = 0
$tt = IniRead("AllWords.ini", "WordLen_" & $NTsection[$iID], $NTkey[$iID], "NotFound")
If $tt <> "NotFound" Then
GUICtrlSetFont($iID, 8, 400, 8, "MS Sans Serif")
IniWrite("AllWords.ini", "WordLen_" & $NTsection[$iID], $NTkey[$iID], "-----")
$delini = True
$delini2 = $delini2 + 1
EndIf
EndIf
If $poisc = True Then
$PerwayaBuk = StringMid($a, $Next, 1)
$poisc2 = StringInStr($answer, $PerwayaBuk)
If $poisc2 > 0 Then
If $Next2 <> $Next Then
$x = $x + 15
If $x > 690 Then
$y = $y + 65
$x = 0
EndIf
$Form1 = GUICtrlCreateLabel (" ", $y, $x, 65, 15)
$NomerTexta = $NomerTexta + 1
$x = $x + 15
If $x > 690 Then
$y = $y + 65
$x = 0
EndIf
$Form1 = GUICtrlCreateLabel ("-=-" & $PerwayaBuk & "-=-", $y, $x, 65, 15)
$NomerTexta = $NomerTexta + 1
$Next2 = $Next
EndIf
_generate()
Else
$Next = $Next + 1
If $Next > 30 Then
$poisc = False
$x = $x + 20
If $x > 690 Then
$y = $y + 65
$x = 0
EndIf
$Form1 = GUICtrlCreateLabel ("Поиск слов Закончили!", $y, $x, 220, 20)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$x = $x + 20
If $x > 690 Then
$y = $y + 65
$x = 0
EndIf
$Form1 = GUICtrlCreateLabel ("Всего слов: " & $VsegoSlov, $y, $x, 200, 20)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
EndIf
EndIf
EndIf
Wend
Func _generate()
$key = $key + 1
$line = IniRead("AllWords.ini", "WordLen_" & $Next & "_" & $NoSek, $key, "NotFound")
If $line = "NotFound" Then
$key = 0
$NoSek = $NoSek + 1
If $NoSek = 10 Then $NoSek = 13 ;; -=-=-=-=-=-=-=-=- уменьнаем зону поиска только в диапазоне 2-9
Else
If $line = "End" Then
$NoSek = 1
$Next = $Next + 1
If $Next > 30 Then
$poisc = False
$x = $x + 20
If $x > 690 Then
$y = $y + 65
$x = 0
EndIf
$Form1 = GUICtrlCreateLabel ("Поиск слов Закончили!", $y, $x, 220, 20)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
;$NomerTexta = $NomerTexta + 1
$x = $x + 20
If $x > 690 Then
$y = $y + 65
$x = 0
EndIf
$Form1 = GUICtrlCreateLabel ("Всего слов: " & $VsegoSlov, $y, $x, 200, 20)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
;$NomerTexta = $NomerTexta + 1
;MsgBox(0, "Поиск слов", "Закончили!")
EndIf
EndIf
If $poisc = True Then
$DlinaSlovarya = StringLen($line)
For $i = 1 To $DlinaSlovarya
$testWord = StringMid($line, $i, 1)
$result = StringInStr($answer, $testWord)
If $result = 0 Then
$No = True
ExitLoop
EndIf
Next
If $No = False Then
For $i = 1 To $DlinaSlovarya
$Word = StringMid($line, $i, 1)
$result = StringInStr($answer2, $Word)
If $result > 0 Then
$answer2 = StringReplace($answer2, $Word, "", 1)
$p = $p + 1
If $p = $DlinaSlovarya Then $Yes = True
If $p <> $DlinaSlovarya Then $Yes = False
Else
$answer2 = $answer
ExitLoop
EndIf
Next
If $Yes = True Then
$x = $x + 15
If $x > 690 Then
$y = $y + 65
$x = 0
EndIf
;MsgBox(0, "New string is", $line)
$Form1 = GUICtrlCreateLabel ($line, $y, $x, 65, 15)
$VsegoSlov = $VsegoSlov + 1
$NomerTexta = $NomerTexta + 1
$NTsection[$NomerTexta] = $Next & "_" & $NoSek
$NTkey[$NomerTexta] = $key
$xx[$NomerTexta] = $x
$yy[$NomerTexta] = $y
;FileWriteLine($file2, $line)
$Yes = False
EndIf
EndIf
$p = 0
$No = False
$Yes = False
$answer2 = $answer
EndIf
EndIf
EndFunc
;FileClose($file)
Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam)
Local Const $STN_DBLCLK = 1, $STN_CLICKED = 0
Local $nID = BitAND($wParam, 0xFFFF)
Local $nNotifyCode = BitShift($wParam, 16)
Switch $nNotifyCode
Case $STN_CLICKED
$iClicked = $nID
Case $STN_DBLCLK
$iDoubleClicked = $nID
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND