scratched the surface of this academic yet useful domain hereexperiment further on your ownand see other books for additional topics ( breadth-first search by levelsand best-first search by path or state scores) :\pp \dstruct\classicspython gtestobj py [[sm][spm][spam]permuting sequences our next data structure topic implements extended functionality for sequences that is not present in python' built-in objects the functions defined in example - shuffle sequences in number of wayspermute constructs list with all valid permutations of any sequence subset constructs list with all valid permutations of specific length combo works like subsetbut order doesn' matterpermutations of the same items are filtered out these results are useful in variety of algorithmssearchesstatistical analysisand more for instanceone way to find an optimal ordering for items is to put them in listgenerate all possible permutationsand simply test each one in turn all three of the functions make use of generic sequence slicing so that the result list contains sequences of the same type as the one passed in ( when we permute stringwe get back list of stringsexample - pp \dstruct\classics\permcomb py "permutation-type operations for sequencesdef permute(list)if not listreturn [listelseres [for in range(len(list))rest list[:ilist[ + :for in permute(rest)res append(list[ : + xreturn res def subset(listsize)if size = or not listreturn [list[: ]elseresult [shuffle any sequence empty sequence delete current node permute the others add node at front order matters here an empty sequence permuting sequences