| |
| | [No title] (Site not responding. Last check: 2007-10-30) |
 | | If you have foo = Permutation(['a','Fred',23,None]) the possible indices are numbered 0 to 23 (0 to 4!-1) sam = foo.permutation(10) mary = foo.permutation(4) sam is ['Fred', None, 'a', 23] mary is ['a', None,'Fred', 23] An interesting thing about the factoradic method is its reversibility. |
 | | If you have a list: ['a','Fred',23,None] and you are presented with an ordering: [23,'a',None,'Fred'] the factoradic method can algorithmically determine that this ordering is index 13 of 24 of the possible permutations, without going forward through your generating algorithm to get there. |
 | | Works by the factoradic method, which provides reversibility.""" _order = None def __init__(self,data=None): if data: self.data = list(data) else: self.data = [] def getOrder(self): if not self._order: self._order = len(self.data) return self._order def setData(self,data): self.data = data self._order = None def permutationIndices(self,index): """calculate the permutation indices of self from index. |
| zif.hill-street.net /factoradic/factoradic.py (856 words) |
|