7 kyu

Cyclops numbers

1,418 of 2,610Nmistrata

Description:

A cyclops number is a number in binary that is made up of all 1's, with one 0 in the exact middle. That means all cyclops numbers must have an odd number of digits for there to be an exact middle.
A couple examples:
101
11111111011111111
You must take an input, n, that will be in decimal format (base 10), then return True if that number wil be a cyclops number when converted to binary, or False if it won't.
Assume n will be a positive integer.

A test cases with the process shown:

cyclops (5)
"""5 in biinary"""
"0b101"
"""because 101 is made up of all "1"s with a "0" in the middle, 101 is a cyclops number"""
return True

cyclops(13)
"""13 in binary"""
"0b1101"
"""because 1101 has an even number of bits, it cannot be a cyclops"""
return False

cyclops(17)
"""17 in binary"""
"0b10001"
"""Because 10001 has more than 1 "0" it cannot be a cyclops number"""
return False

n will always be > 0.

Algorithms

Stats:

CreatedFeb 2, 2016
PublishedFeb 2, 2016
Warriors Trained4381
Total Skips64
Total Code Submissions13020
Total Times Completed2610
Python Completions1418
Ruby Completions163
C Completions120
JavaScript Completions779
Java Completions210
Total Stars54
% of votes with a positive feedback rating94% of 454
Total "Very Satisfied" Votes406
Total "Somewhat Satisfied" Votes41
Total "Not Satisfied" Votes7
Ad
Contributors
  • Nmistrata Avatar
  • CrazyMerlyn Avatar
  • smile67 Avatar
  • Madjosz Avatar
  • rowcased Avatar
  • user8436785 Avatar
  • yLaWy Avatar
Ad