def parti2 (list, equalFunc):
    n = len(list)
    equals = []
    tests = Combo114.combo (n)
    a=0
    while len(tests):
         (key, (a,b)) = tests.popitem()
         a=a+1
         if equalFunc( list[a-1], list[b-1] ):
              equals.append( (a,b) )
              Combo114.reduce (tests, (a,b))
    equals += [(i,i) for i in range(1,n+1)]
    print 'parti 2 run', a
    return Combo114.merge (equals)
Пример #2
0
import Combo114

#aa = {1:(5,6),3:(7,6)}
#
#for k in aa.itervalues():
#    a2=aa.copy()
#    m=a2.popitem()
#    print m
#print aa
#print a2


a= Combo114.combo(120)
if ( Combo114.reduce( a, [2,3]) ==  Combo114.reduce2( a, [2,3]) ):
    print 'yea'
else:
    print 'na'