0
\$\begingroup\$

The task is the following:

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!

\$\endgroup\$
  • 2
    \$\begingroup\$ 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) \$\endgroup\$ – Sp3000 Oct 19 '15 at 13:47
  • \$\begingroup\$ Closely related. \$\endgroup\$ – Martin Ender Oct 19 '15 at 13:53
  • \$\begingroup\$ you're completely right. It was a typo and I mean indeed consecutive series of ones :) \$\endgroup\$ – DPF Oct 19 '15 at 13:53
  • 1
    \$\begingroup\$ 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! \$\endgroup\$ – Rainbolt Oct 19 '15 at 13:56
  • \$\begingroup\$ 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. \$\endgroup\$ – Martin Ender Oct 19 '15 at 14:32