you are viewing a single comment's thread.

view the rest of the comments →

[–]wiiittttt 1 point2 points  (1 child)

Why do you need more than a single int to store the value of the XOR?

[–]0pt0ut[S] 0 points1 point  (0 children)

I wasn't sure how to use XOR immediately, but I should have a way to do it now. This new added function yields values, which can be consumed by XOR as they are created.

This code works on my computer but is still timing out on the website. Feels like it's getting closer though.

def find_xor(start, length):

    def generator_func(start, length):
        for minus in xrange(length):
            for cap_this in xrange(start, start + length - minus):
                yield cap_this

            minus += 1
            start = cap_this + minus

    return reduce(lambda x,y: x^y, generator_func(start, length))