I have a function that calculates the next unique value on the fly. These values are 100% unique except one. Each value is 256 bit, total values are 2128. The amount of space needed to store this many values is obviously too large: (2128 x 256 bits) How can i find these 2 duplicates indexes from starting point? I tried to XOR each value with next, but when function returns duplicate i cant figure out that this is duplicate because XOR excludes it from crc. simple example:
a=[755,167,986,343,566,996,245,343]
crc=a[0]
for i in range(1,len(a)):
crc=crc ^ a[i]
this code makes crc like crc([755,167,986,566,996,245]) right answer for this example is 343 or #4 (3 if counting from 0) best code that i can produce is double for from ending element till start, and from current element of main for till end:
for i in range(maxX,1,-1):
crc=crc^x1
for j in range(i+1,maxX):
if(x1==x2):
break
x2 = f(x2)#iterate x2 back like "f(x2,+1)"
x1=f(x1) #iterate x1 forward like "f(x1,-1)"
Are there any subexponential algorithms to solve this problem?
function produces values like : f(x1)=13082069741720843297365566874415150979823939205374148607908286415326657186361
in fact there is no difference for me coding python/c/javascript/php/asm, so the code for answer accepted in any language Any fastest algorithm for finding 2 duplicates for this?