Skip to main content
11 events
when toggle format what by license comment
Mar 21, 2017 at 16:54 vote accept MauroAlmeida
Mar 21, 2017 at 13:00 answer added Toby Speight timeline score: 2
Mar 21, 2017 at 11:44 comment added CiaPan Input like 0xF is not 'all 1's' because it actually is 0x0000000F for 32-bit int, hence 3 is a correct answer: the longest chain of alternating bits in the given number is a two-bit sequence 01 at positions 4 and 3.
Mar 21, 2017 at 11:26 comment added CiaPan The two masks given by @TobySpeight are alternating binary sequences: zero-one-zero-one... or one-zero-one-zero-... So if you XOR one of them with your number, every alternating subsequence would be converted either into a contiguous block of zeros or a block of ones.
Mar 21, 2017 at 11:14 history edited MauroAlmeida CC BY-SA 3.0
deleted 2 characters in body
Mar 21, 2017 at 11:13 comment added MauroAlmeida @TobySpeight I don't understand your observation can you explain it better in an answer?
Mar 21, 2017 at 9:03 comment added Toby Speight One observation: If you already have a function that will find a sequence of identical bits, you can transform the input by XOR with 0x5555... (to the length of your type) or 0xAAAA... and then the problem is equivalent.
Mar 21, 2017 at 4:32 history edited 200_success
edited tags
Mar 21, 2017 at 0:36 review First posts
Mar 21, 2017 at 2:28
Mar 21, 2017 at 0:35 history edited Jamal CC BY-SA 3.0
deleted 93 characters in body; edited title
Mar 21, 2017 at 0:30 history asked MauroAlmeida CC BY-SA 3.0