On Sun, Jan 12, 2014 at 7:44 AM, Alan Gauld <alan.ga...@btinternet.com> wrote: > OK< So there is nothing here about the orders being the same. > That makes it much easier.
There's another approach, I think, that's quite easy if order IS important. Iterate through the letters of product, find() them initially from the beginning of debris, and then from the index of the last letter found. Accounts for multiples in product, & order. def fix_machine(debris, product): index = 0 success = False for letter in product: test = debris.find(letter, index) if test: index = test else: # Failure return "Give me something that's not useless next time." return product # Success I suspect this could be done in one line, without regex, but it would probably take me a week to figure out... maybe next week ;) -- Keith _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor