# Check if a given 8-bit Number is sparse [duplicate]

Program the shortest fully functional program that checks, if an 8-bit value contains a consecutive sequence of 2 or more ones in its binary form.

If it does contain such a sequence, the output shall be 0. If not: 1.

Examples:

Input: 1 Output: 1

Input: 3 Output: 0

Input: 72 Output: 1

Input: 75 Output: 0

The shortest solution wins!

• Welcome to PPCG! I'm a little confused though, so may I ask a few questions? 1) "If this is the case, the output shall be 1, if not: 1." Should one of these be a 0? and 2) Does a sequence mean a consecutive sequence like 11? If so, how do the last two cases work? (72 = 1001000, 73 = 1001001) – Sp3000 Oct 19 '15 at 13:47
• Closely related. – Martin Ender Oct 19 '15 at 13:53
• you're completely right. It was a typo and I mean indeed consecutive series of ones :) – DPF Oct 19 '15 at 13:53
• I fixed one more place where the typo was, and added the "code-golf" tag. I strongly suggest that you read the tag wiki to get a general idea of what the tag is about. There are some folks checking for duplicates of your question. If they find none, I'm sure they will vote to reopen your question. Welcome to PPCG! – Rainbolt Oct 19 '15 at 13:56
• I do think this is a duplicate of the challenge I linked. The only real golfing trick that can be applied here is x&2*x which almost all of the answers on the other challenge already use. All answers to this challenge would do is taken an answer from there and remove the loop. – Martin Ender Oct 19 '15 at 14:32