Problems
A research consortium has been looking for the best possible database for three years, but
they are still having problems. The database stores values as records that hold
Each record of the database is an
- Choose an integer
r between0 and7 , inclusive, and letW be likeV but rotated byr to the right. That is, the((i + r) \bmod 8) -th bit ofW is thei -th bit ofV . - Replace the current value
X of the record withX XORW . That is, the new value of the record has a1 as itsi -th bit if and only if thei -th bits ofX andW are different. - Finally, return the number of bits that are
1 in the new value to the user.
Luckily, it turns out that no matter what the initial value is or what rotation values the database
chooses, it is always possible to reset the value of a record to have all bits be