(self, func)
return diff
Estimate how many steps it takes to reach ``func`` from self.
            Return -1 if impossible.
Estimate how many steps it takes to reach ``func`` from self.
            Return -1 if impossible.
Estimate how many steps it takes to reach func from self . Return - 1 if impossible .
def difficulty(self, func):
        """ Estimate how many steps it takes to reach ``func`` from self.
            Return -1 if impossible. """
        if self.gamma != func.gamma:
            return -1
        oabuckets, obbuckets, abuckets, bbuckets = [sift(params, _mod1) for
                params in (self.ap, self.bq, func.ap, func.bq)]

        diff = 0
        for bucket, obucket in [(abuckets, oabuckets), (bbuckets, obbuckets)]:
            for mod in set(list(bucket.keys()) + list(obucket.keys())):
                if (not mod in bucket) or (not mod in obucket) \
                        or len(bucket[mod]) != len(obucket[mod]):
                    return -1
                l1 = list(bucket[mod])
                l2 = list(obucket[mod])
                l1.sort()
                l2.sort()
                for i, j in zip(l1, l2):
                    diff += abs(i - j)

        return diff
def difficulty ( self , func ) : if self . gamma != func . gamma : return - 1 oabuckets , obbuckets , abuckets , bbuckets = [ sift ( params , _mod1 ) for params in ( self . ap , self . bq , func . ap , func . bq ) ] diff = 0 for bucket , obucket in [ ( abuckets , oabuckets ) , ( bbuckets , obbuckets ) ] : for mod in set ( list ( bucket . keys ( ) ) + list ( obucket . keys ( ) ) ) : if ( not mod in bucket ) or ( not mod in obucket ) or len ( bucket [ mod ] ) != len ( obucket [ mod ] ) : return - 1 l1 = list ( bucket [ mod ] ) l2 = list ( obucket [ mod ] ) l1 . sort ( ) l2 . sort ( ) for i , j in zip ( l1 , l2 ) : diff += abs ( i - j ) return diff