Sign in to follow this  
Followers 0
Jasio

Comparing Variables For Value (Comparing to multiple Variables)

4 posts in this topic

#1 ·  Posted (edited)

Ok, for my script i have to compare checksums, which are created by giving the letters a - z Prime Numbers, 2, 3, 5, 7, etc. Respectively. This script descrambles words using the checksums, so, if someone inputs REODR, the script mutliplies the letters, and finds the checksum, which in this case would give the user the value 'order' as the unscrambled word. Now, i need to have the script compare the checksum to the values of other words:

$hicks = 4538245
$hid = 3059
$hidden = 10128349
$hide = 33649
$hideaway = 1083632396
$hideaways = 72603370532
$hidebound = 104251096257

Thanks for any help,

Jasio-

Edited by Jasio

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Ok, for my script i have to compare checksums, which are created by giving the letters a - z Prime Numbers, 2, 3, 5, 7, etc. Respectively. This script descrambles words using the checksums, so, if someone inputs REODR, the script mutliplies the letters, and finds the checksum, which in this case would give the user the value 'order' as the unscrambled word. Now, i need to have the script compare the checksum to the values of other words:

$hicks = 4538245
$hid = 3059
$hidden = 10128349
$hide = 33649
$hideaway = 1083632396
$hideaways = 72603370532
$hidebound = 104251096257
oÝ÷ Ù8ZK¢¶§Ê¥¤¬êº^" ;{}Ø¢è(¶Ê&zH§váj·¢·W«+hjºÚÊÊ+²¶§¹bF®¶­sb6æ6ÇVFRfÇC¶'&æS2fwC° ¤FÒb33c¶v÷&G5³ÒÒ³ÒÂb33c¶6µ7V×5³ÒҳР£²W6RvFWfW"67&BgVæ7Föç2÷Rb33·fRÇ&VGv÷BFò÷VÆFRFRÆ7Böbv÷&G2æB6V6·7V×3 ¥ôFEv÷&BgV÷C¶BgV÷C²Ã3S¥ôFEv÷&BgV÷C¶FFVâgV÷C²Ã#3C¥ôFEv÷&BgV÷C¶FRgV÷C²Ã33cC¥ôFEv÷&BgV÷C¶FVvgV÷C²Ã3c3#3b¥ôFEv÷&BgV÷C¶FVv2gV÷C²Ãs#c33sS3"¥ôFEv÷&BgV÷C¶FV&÷VæBgV÷C²ÃC#Sc#Sr ¥vÆR¢b33cµ6V&67VÒÒçWD&÷gV÷Cµv÷&B6V&6gV÷C²ÂgV÷C´VçFW"FR6V6·7VÒFò6V&6f÷#¢gV÷C²¢bæ÷BW'&÷"FVà¢b33c·5&W7VÇBÒôfæEv÷&Bb33cµ6V&67VÒ¢×6t&÷cBÂgV÷Cµv÷&B6V&6gV÷C²ÂgV÷C´6V6·7VÒgV÷C²fײb33cµ6V&67VÒfײgV÷C²ÖF6VC¢gV÷C²fײb33c·5&W7VÇB¢VÇ6P¢WDÆö÷¢VæD`¥vVæ@ £²FBv÷&BæBG26V6·7VÒFòFRÆ7G0¤gVæ2ôFEv÷&Bb33c·5v÷&BÂb33c¶6µ7VÒ¢ô'&FBb33c¶v÷&G2Âb33c·5v÷&B¢b33c¶v÷&G5³ÒÒV&÷VæBb33c¶v÷&G2Ò¢ô'&FBb33c¶6µ7V×2Âb33c¶6µ7VÒ¢b33c¶6µ7V×5³ÒÒV&÷VæBb33c¶6µ7V×2Ò¤VæDgVæ0  £²fæBv÷&B'G2ÖF6ær6V6·7VФgVæ2ôfæEv÷&Bb33c¶6µ7VÒ¢Æö6Âb33c¶0¢f÷"b33c¶2ÒFòb33c¶6µ7V×5³Ð¢bb33c¶6µ7V×5²b33c¶5ÒÒb33c¶6µ7VÒFVâ&WGW&âb33c¶v÷&G5²b33c¶5ТæW@¢&WGW&âgV÷C²fÇC´æ÷Bf÷VæBfwC²gV÷C°¤VæDgVæ

Make your life MUCH easier and use some arrays! :whistle:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

This was fun. In this case, I read the words and the checksums from a file into an array:

#include <array.au3>

Const $ForReading = 0, $ForAppending = 1, $ForWriting = 2
$timeStart = TimerInit()
SplashTextOn( "Checksums", " Reading values", 200, 35, @DesktopWidth - 210, @DesktopHeight - 90, 20, "Arial", 9)

$file = @ScriptDir & "\words.txt"
$fileText = FileRead($file, FileGetSize($file))   ; Read in all the text
$afileText = StringSplit($fileText, @CRLF, 1)   ; Split into lines
Dim $aWords[$afileText[0] + 1][2]
$aWords[0][0] = $afileText[0]
For $i = 1 to $afileText[0]   ; Parse each line into word and checksum
    $line = $afileText[$i]
    $aWords[$i][0] = StringStripWS ( StringLeft($line, StringInStr($line, "=") - 1), 3 )
    $aWords[$i][1] = StringStripWS ( StringRight($line, StringLen($line) - StringInStr($line, "=")), 3 )
    If Int($i/25) = $i/25 Then
        ControlSetText("Checksums", "", "Static1", " Reading value " & $i & " of " & _
        $afileText[0] & "..." & @CRLF & "  Please wait...")
    EndIf
    $afileText[$i] = ''
Next

$afileText = ""
SplashOff()
MsgBox(0, "Time to load", "Time to load all words and checksums: " & _
    Round(TimerDiff($timeStart)/1000, 2) & " secs.")

While 1
    $SearchSum = InputBox("Word Search", "Enter the checksum to search for:  ")
    If Not @error Then
        $timeStart = TimerInit()
        $sResult = _FindWord($SearchSum)
        MsgBox(64, "Word Search", "Checksum " & $SearchSum & " matched: " & $sResult & _
            @LF & "Time to find: " & Round(TimerDiff($timeStart)/1000, 2) & " secs." )
    Else
        ExitLoop
    EndIf
Wend

; Find a word by its matching checksum
Func _FindWord($iChkSum)
     Local $c
     For $c = 1 To $aWords[0][0]
          If $aWords[$c][1] = $iChkSum Then Return $aWords[$c][0]
     Next
     Return "<Not Found>"
EndFunc

I built a dictionary file ("words.txt") of 4000+ words and checksums with this format:

<word> = <checksum>

It took less than a second to load the words, and then about a quarter second to find a word that matched a checksum near the end of the file. I don't even think that it is necessary to optimize searches by sorting the array.


BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0