def getTuples(cards, notIn, ofLength): if ofLength==1: if cards not in notIn: return 1 return 0 else: cnt=0 for tup in tupleRange(cards): if tup not in notIn: notIn = notIn.union([tup]) cnt += getTuples(tupleDiff(cards,tup), notIn, ofLength-1) return cnt