The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
Flooding from Sandy made that a lot easier for me as it was done for me by the Atlantic and I lived for nine months in a house with a major save-everything problem. Still hard, but not so hard as it used to be. Even empty containers that I absolutely know I'll need.
Isympathise, about a year ago Harvey hit Houston and it flooded my home andf office. I lost everything, but my sob in law salvaged my hard drive, so my files were intact, but I lost my diplomas and certificates and am just now getting them replaced. I was able to get s new copy of my distinguished member certificate from The Society of Petroleum Engineers and yesterday my Professional Engineer registration was finally completed.
CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004
There are various ways to solve this of course, but one way could be:
The lowest non-zero shift count is 3, so the top 3 bits are the original bits. The next 3 bits from the top have the top bits XORed into them, and they can be restored by again XORing with the top bits:
x ^= x >> 3;
Now the top 6 bits are decoded, but the rest of the bits are "more tangled up". Proceeding that way does keep making progress because it always makes the decoded part at least 1 bit longer, but as it does so it makes the bottom bits more and more messed up. That's tricky to keep track of just in my mind, so what I would do is represent the current state of "how tangled up" the message is an an ulong (m) that has bit k set iff x is still XORed with the original message shifted right by k. So m = 1 | (1UL << 3) | (1UL << 13) | (1UL << 47) at the start, and when restoring that first group of bits it changes in a similar way: m ^= m << 3;.
The next offset can be found by looking in m for the rightmost set bit apart from the least significant bit, so offset = countTrailingZeros(m & ~1UL). The second offset is 6, then 12, 13, 16, 19, 22, etc.
As a variant, a similar thing can be done but xoring x with shifted versions of the original encoded message instead of the current x, which would be paired with xoring m with shifted versions of the original m instead of the current m. Then the offset sequence is 3, 6, 12, 13, 15, 18, 19, 21...
Or if you immediately see what's going on, you can relate this problem to finding the carryless multiplicative inverse modulo 264, but you didn't need that just to solve the puzzle.