예제 #1
0
    def rt_equiv(self, other):
        if UT.is_satisfies(RT.IPersistentVector, other):
            if UT.equiv(RT.count.invoke1(self), UT.count(other)) is false:
                return false
            for x in range(self._cnt):
                i = wrap_int(x)
                if RT.equiv(RT.nth.invoke1(self, i), UT.nth(self, i)) is false:
                    return false
            return true
        else:
            if RT.is_satisfies.invoke1(RT.Sequential, other) is false:
                return false
            ms = RT.seq.invoke1(other)

            for x in range(self._cnt):

                if ms is nil or UT.equiv(UT.nth(x, wrap_int(x)), UT.first(ms)) is false:
                    return false


                ms = UT.next(ms)

            if ms is not nil:
                return false

        return true
예제 #2
0
    def rt_equiv(self, other):
        if UT.is_satisfies(RT.IPersistentVector, other):
            if UT.equiv(RT.count.invoke1(self), UT.count(other)) is false:
                return false
            for x in range(self._cnt):
                i = wrap_int(x)
                if RT.equiv(RT.nth.invoke1(self, i), UT.nth(self, i)) is false:
                    return false
            return true
        else:
            if RT.is_satisfies.invoke1(RT.Sequential, other) is false:
                return false
            ms = RT.seq.invoke1(other)

            for x in range(self._cnt):

                if ms is nil or UT.equiv(UT.nth(x, wrap_int(x)),
                                         UT.first(ms)) is false:
                    return false

                ms = UT.next(ms)

            if ms is not nil:
                return false

        return true
예제 #3
0
    def rt_hash(self):
        if self._hash is None:
            n = r_uint32(0)
            hash = r_uint32(1)
            for x in range(self._cnt):
                hash = r_uint32(31) * hash + UT.hash(UT.nth(wrap_int(x)))._int_value
                n += 1
                x = RT.next.invoke1(x)

            self._hash = wrap_int(int(mix_col_hash(hash, n)))

        return self._hash
예제 #4
0
    def rt_hash(self):
        if self._hash is None:
            n = r_uint32(0)
            hash = r_uint32(1)
            for x in range(self._cnt):
                hash = r_uint32(31) * hash + UT.hash(UT.nth(
                    wrap_int(x)))._int_value
                n += 1
                x = RT.next.invoke1(x)

            self._hash = wrap_int(int(mix_col_hash(hash, n)))

        return self._hash
예제 #5
0
def problem9(n):
  return util.product(util.nth(1, ((a,b,c) for a in xrange(1, n) for b in xrange(1, n) for c in xrange(1, n) if a+b+c == n and a**2 + b**2 == c**2)))
예제 #6
0
def problem024():
  return util.nth(int(1e6) - 1, permute('0123456789'))
예제 #7
0
def problem7(n):
  return util.nth(n, primes.erat2())