Click here to Skip to main content
14,330,041 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

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.
 
GeneralRe: Friday Afternoon Puzzle Pin
harold aptroot3-May-19 1:19
memberharold aptroot3-May-19 1:19 
GeneralRe: Friday Afternoon Puzzle Pin
Rob Philpott3-May-19 1:41
memberRob Philpott3-May-19 1:41 
GeneralRe: Friday Afternoon Puzzle Pin
harold aptroot3-May-19 1:55
memberharold aptroot3-May-19 1:55 
GeneralRe: Friday Afternoon Puzzle Pin
Michael Martin3-May-19 1:59
professionalMichael Martin3-May-19 1:59 
GeneralRe: Friday Afternoon Puzzle Pin
PIEBALDconsult3-May-19 3:07
protectorPIEBALDconsult3-May-19 3:07 
GeneralRe: Friday Afternoon Puzzle Pin
Richard Deeming3-May-19 3:32
mveRichard Deeming3-May-19 3:32 
GeneralRe: Friday Afternoon Puzzle Pin
OriginalGriff3-May-19 4:11
protectorOriginalGriff3-May-19 4:11 
GeneralRe: Friday Afternoon Puzzle [spoilers] Pin
harold aptroot3-May-19 7:22
memberharold aptroot3-May-19 7:22 
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.
GeneralI win! Pin
CPallini4-May-19 11:29
mveCPallini4-May-19 11:29 
GeneralThe Misinformation Age Pin
Randor 2-May-19 23:05
professional Randor 2-May-19 23:05 
GeneralRe: The Misinformation Age Pin
Christian Graus2-May-19 23:10
protectorChristian Graus2-May-19 23:10 
QuestionRe: The Misinformation Age Pin
Randor 2-May-19 23:19
professional Randor 2-May-19 23:19 
AnswerRe: The Misinformation Age Pin
Christian Graus2-May-19 23:21
protectorChristian Graus2-May-19 23:21 
GeneralRe: The Misinformation Age Pin
Randor 2-May-19 23:30
professional Randor 2-May-19 23:30 
GeneralRe: The Misinformation Age Pin
Christian Graus2-May-19 23:33
protectorChristian Graus2-May-19 23:33 
GeneralRe: The Misinformation Age Pin
RJOberg3-May-19 2:53
professionalRJOberg3-May-19 2:53 
GeneralRe: The Misinformation Age Pin
den2k882-May-19 23:31
professionalden2k882-May-19 23:31 
GeneralRe: The Misinformation Age Pin
Christian Graus2-May-19 23:32
protectorChristian Graus2-May-19 23:32 
GeneralRe: The Misinformation Age Pin
den2k882-May-19 23:37
professionalden2k882-May-19 23:37 
GeneralRe: The Misinformation Age Pin
Christian Graus2-May-19 23:40
protectorChristian Graus2-May-19 23:40 
GeneralRe: The Misinformation Age Pin
Sander Rossel2-May-19 23:39
professionalSander Rossel2-May-19 23:39 
GeneralRe: The Misinformation Age Pin
den2k882-May-19 23:41
professionalden2k882-May-19 23:41 
GeneralRe: The Misinformation Age Pin
Sander Rossel2-May-19 23:51
professionalSander Rossel2-May-19 23:51 
GeneralRe: The Misinformation Age Pin
Christian Graus2-May-19 23:41
protectorChristian Graus2-May-19 23:41 
GeneralRe: The Misinformation Age Pin
Sander Rossel2-May-19 23:48
professionalSander Rossel2-May-19 23:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.