I want to find all possible combinations of letters and digits restricted to a given length. The results of a simplified example using the letters "abc" and restricted to a length of 2 would be:
Quote:
AA
AA
AB
AC
BA
BB
BC
CA
CB
CC
I started to adapt
this script of Zed Gecko:
Code:
SetBatchlines -1
#NoEnv
loop, 3 ;26 chars + 9 digits
{
AsciNum := A_Index + 64 ;48
if (AsciNum > 57 and AsciNum < 65)
continue
baselist .= Chr(AsciNum)
}
new_newlist := makelists(baselist, "")
MsgBox %list_idx% strings created:`n`n%FinalList%
;fileappend, %FinalList%, permutations.txt
Return
makelists(baselist, newlist)
{
loop, parse, baselist
{
global rec_depth
thischar := A_Loopfield
StringReplace, newbaselist, baselist, %thischar%,, All
new_newlist := newlist . thischar
if (newbaselist = "")
{
rec_depth := 0
Tooltip, %rec_depth%, 0, 40, 2
newlist(new_newlist)
}
else
{
rec_depth ++
Tooltip, %rec_depth%, 0, 40, 2
makelists(newbaselist, new_newlist)
}
}
return new_newlist
}
newlist(newlist)
{
global FinalList
global list_idx
SetFormat, float, 3.0
list_idx ++
FinalList := FinalList . "`n" . newlist
tooltip %list_idx%, 0, 0, 1
return
}
which can produce this kind of list:
Quote:
ABC
ACB
BAC
BCA
CAB
CBA
But I'm lost as to what to do next:
1. I have no idea how to implement a restriction on the total length of the string.
2. I have no idea how to specify that the same letters can occur multiple times in the string.
3. I have used, but never written recursive functions before. Where to start?
I wanted to see if it was possible to write a script which would use the above mentioned functions together with URLDownloadToVar to find available and short domain names in certain country domains (Such as .no, .ca etc.).
If URLDownloadToVar returns 0, the script would assume the domain is available. Although this is probably not a sure-fire solution, it avoids (mis)use of online domain whois database.