def generateIndexList(size:int,maxLength:int)->list: maxLength = min(size,maxLength) # print("MaxLen:"+str(maxLength)) indexArrayList = dict() indexArray = ArrayList() for i in range(0, size): indexArray.append(i) for i in range(0, size): newArray = ArrayList() IndexGenerator.__go(indexArrayList, newArray.copy(), indexArray.copy(), i, maxLength) array = ArrayList() for each in indexArrayList.values(): array.append(each) array.sort() return array
def generateAllPossibleIndexes(indexCount:int,maxLength:int)->list: finalArray = ArrayList() for i in range(0,indexCount): finalArray.append(i) array = finalArray.copy() for i in range(0,maxLength-1): finalArray = IndexGenerator.arrayObjectCrossProduct(finalArray,array) return finalArray
def __go(indexArrayList: dict, current: ArrayList, left: ArrayList, i:int, maxLength:int): length = current.__len__() if length >= maxLength: indexArrayList.setdefault(current.__str__(),current) # Debug.print("add:"+current.__str__()) return else: current.append(left.pop(i)) length = left.__len__() # Debug.print("Cur:" + current.__str__() + " Left:" + left.__str__() + " len =" + str(length), end="") # Debug.print(" index:" + str(i)) a = 0 if a<length: while a < length: IndexGenerator.__go(indexArrayList,current.copy(), left.copy(), a, maxLength) a += 1 else: indexArrayList.setdefault(current.__str__(), current) # Debug.print("add:" + current.__str__()) return