← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #217327]: how to create x lists from a given list, each new list created by removing an element

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
ok, perfect.

This the Python for your workflow:

import random

# possible outer loop
lineIn = "wyorgb" # read next input line
colors = [lineIn[i] for i in range(len(lineIn))] # build colorlist from lineIn
random.seed() # reset randomizer

for i in range(len(lineIn)):
    c = random.choice(colors) 
    colors.remove(c)
    lineOut = ""
    for c in colors: lineOut+=c # rebuild a string to output
    print lineOut # write a color combination
    if not colors: break


You can now add the file handling at the 2 points (read ..., write ...) creating an additional outer loop

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