 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Leroxy
Joined: 06 Dec 2007 Posts: 52
|
Posted: Sat Jan 19, 2008 6:52 am Post subject: scrambled eggs |
|
|
I faced the challenge on making scrambeld eggs with letters.
For instance:
Ask user for input: AHK
Loop, ahk into
output
ahk
hak
kah
akh
hka
kha
{I think thats all combinations }
So I think about split user input string and then loop into the preferable output form.
But how todo it (the loop) could someone point me into the direction on how too get this done.
Thank you ,
Leroxy  |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Sat Jan 19, 2008 8:00 am Post subject: |
|
|
| Code: | Loop 1000
List .= Scramble( "AHK") "`n"
Sort List, U D`n
MsgBox, % List
Scramble( Word ) {
; Laszlo: http://www.autohotkey.com/forum/viewtopic.php?p=163269#163269
V := RegExReplace( Word,"(.)", "$1|" )
Sort V, Random D|
StringReplace, V, V, |,, All
Return V
} |
 |
|
| Back to top |
|
 |
Leroxy
Joined: 06 Dec 2007 Posts: 52
|
Posted: Sat Jan 19, 2008 9:46 am Post subject: |
|
|
Omg
It works and very well indeed.
Only I did forget that its also possible too make this
AHK
A
H
K
AH
AK
HA
HK
KA
KH
AHK
AKH
HKA
HAK
KAH
KHA
Gimme another push
Thank you,
Leroxy  |
|
| Back to top |
|
 |
Leroxy
Joined: 06 Dec 2007 Posts: 52
|
Posted: Sat Jan 19, 2008 3:47 pm Post subject: |
|
|
I am trying todo this but this isnt working why ?
| Code: |
Loop 1000
List .= Scramble( "abcdef") "`n"
Sort List, U D`n
StringTrimRight, List, List, 3
Sort List, U D`n
MsgBox, % List
Scramble( Word ) {
; Laszlo: http://www.autohotkey.com/forum/viewtopic.php?p=163269#163269
V := RegExReplace( Word,"(.)", "$1|" )
Sort V, Random D|
StringReplace, V, V, |,, All
Return V
} |
The list gives all the possible combination until 6 positions.
What I am trying too get is:
abc
acb
bac
bca
cab
cba
def
dfe
edf
efd
fde
fed
bcd
bdc
cbd
cdb
dbc
dcb
I could go on but... lol
1st pos A or B or C or D or E or F
2nd pos A or B or C or D or E or F
3nd pos A or B or C or D or E or F
that would be 6x6x6 combinations.
trying too achieve this with trim right removing 3 postion
and not returning me double or multiple abc abc abc with Sort List
The Bold text in the code.
Could anybody have a idea about it?
leroxy  |
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 320
|
Posted: Sat Jan 19, 2008 3:54 pm Post subject: |
|
|
theres another way of doing it too, like password bruters work, have a variable with your charset, Then have a loop, it starts at the first letter of the given string then loops through the charset and changes the first letter in this case "A" ("AHK") then keep checking to see if it reached the end of your charset "Z"? if it did then set that back to "A" and then do the same with the next character "H" ("AHK")
or you could use SKAN's code and save alot of time  _________________ `Autohotkey User`
- I3egohan |
|
| Back to top |
|
 |
Leroxy
Joined: 06 Dec 2007 Posts: 52
|
Posted: Sat Jan 19, 2008 8:01 pm Post subject: |
|
|
| Code: |
InputBox inputstring, Input, Type in some letters Please ,, 160, 140 ,450,100
Loop 46700
{
List := Scramble(inputstring)
List6 .= List "`n"
StringTrimRight, List, List, 1
List5 .= List "`n"
StringTrimRight, List, List, 1
List4 .= List "`n"
StringTrimRight, List, List, 1
List3 .= List "`n"
}
Sort List3, U D`n
send % List3
Sort List4, U D`n
send % List4
Sort List5, U D`n
send % List5
Sort List6, U D`n
send % List6
reload
Scramble( Word ) {
; Laszlo: http://www.autohotkey.com/forum/viewtopic.php?p=163269#163269
V := RegExReplace( Word,"(.)", "$1|" )
Sort V, Random D|
StringReplace, V, V, |,, All
Return V
}
|
This is my new working code only I think it could be done better leave
your opinion please. And when the list is sending I can't interrupt it ?
Leroxy  |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sun Jan 20, 2008 6:20 pm Post subject: |
|
|
probably this interest you and you might adapt the code. it was originally designed to make every possible UPPER/LOWER case combination from a given word
| Code: | ; CapsCombo.ahk
; ===============
; This Scrippet lets You input any String and
; outputs every possible Upper/LowerCase Combination
;
; toBin function copyrights to Titan
; found in http://www.autohotkey.com/forum/viewtopic.php?t=13522
;
; release under zlib license
; (c) 12/2007 derRaphael
Gui, Add, Edit, x5 vstr w300 r1, EnterYourText
Gui, Add, Button, yp x310 w80 h20 gStartMagic, Go!
Gui, Add, Edit, +ReadOnly x5 w390 r25 vCapsResult
Gui, Show,, Show me every single capitalized Combination
return
GuiClose:
ExitApp
StartMagic:
empty=
GuiControlGet, str,, str ; Get our String
Loop, % strLen(str) ; make up a zeroFilled str length equals length
zeroFilled .= "0" ; of our input str
; this loops every possible UpperLowerCase Combo
; due to its nature, we have two possibilities
; (upper/lower) therefor we only need to compute
Loop, % 2**strLen(str) ; possibilities power length to get total number
{
variation := SubStr(zeroFilled,1,strLen(str)-StrLen(toBin(A_Index-1)))
variation .= toBin(A_Index-1)
Loop, Parse, variation ; variation is the Binary version of every
{ ; possible Upper/Lower Case combination
if (A_LoopField) { ; if our value in variation is 1 make it uppercase
list .= strUpper(SubStr(str,A_Index,1))
} else { ; else make it lowercase
list .= strLower(SubStr(str,A_Index,1))
}
}
list .= "`r`n" ; add linefeed
}
GuiControl,,CapsResult,%list%
return
; Function Calls **************************************************************
strUpper(str){ ; wrapper function for StringUpper
StringUpper, str, str
Return, str
}
strLower(str){ ; wrapper for StringLower
StringLower, str, str
Return, str
}
; toBin origin from Titan. Thanks!
; http://www.autohotkey.com/forum/viewtopic.php?t=13522
; regExModded to remove leading zeros
toBin(i, s = 0, c = 0) {
l := StrLen(i := Abs(i + u := i < 0))
Loop, % Abs(s) + !s * l << 2
b := u ^ 1 & i // (1 << c++) . b
Return, RegExReplace(b,"^0+")
} |
origin thread can be found here
greets
derRaphael _________________
|
|
| Back to top |
|
 |
Leroxy
Joined: 06 Dec 2007 Posts: 52
|
Posted: Sun Jan 20, 2008 9:25 pm Post subject: |
|
|
Vielen dank
My code did his work and doesnt need upper and lower case.
Probaly will come handy for another purpose, Thank you.
P.s. it was a game I needed the script for and I did it got over the
1M points I was trying too proof a point that games can be won by the computer.
Greetz, Leroxy  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|