← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #189649]: Try a lot of possibility of code

 

Question #189649 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/189649

    Status: Open => Answered

RaiMan proposed the following answer:
Here you are:

# length of the word to construct
max = 6

# the alphabet to select the letters
#abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
abc = "ABCDEF"

# the array, to build the word
word = []
word = [word.append("") for i in range(max)]

# the recursive function 
def nextLetter(i):
    for b in abc:
        word[i] = b
        for i1 in range(i+1, max):
            nextLetter(i1)
        w = ""
        for x in word: w += x
        # next word ready
        doSomething(w)

# here goes what you want to do with the word        
def doSomething(w):
    f.write(w+"\n")

# here is the main workflow
# chose appropriate filename 
f = file("/Users/rhocke/out.txt", "w")
for i in range(max):
    nextLetter(i)
f.close()

This is some kind of recursive programming.
Every time the function doSomething is called, a new word of 6 letters is ready to be processed. So you have to put your typing and testing in there.

To test the functionality as such, I have reduced the "alphabet" to the
first 6 letters and the payload is, that I write the words into a file.

Be aware of the additional comments in the code.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.