7 kyu

Shared Bit Counter

260 of 2,409Anarki

Description:

Complete the method that returns true if 2 integers share at least two 1 bits, otherwise return false. For simplicity assume that all numbers are non-negative.

Examples

 7  =  0111 in binary
10  =  1010
15  =  1111
  • 7 and 10 share only a single 1-bit (at index 2) --> false
  • 7 and 15 share 3 1-bits (at indexes 1, 2, and 3) --> true
  • 10 and 15 share 2 1-bits (at indexes 0 and 2) --> true

Hint: you can do this with just string manipulation, but binary operators will make your life much easier.

Fundamentals
Binary
Bits

More By Author:

Check out these other kata created by Anarki

Stats:

CreatedFeb 16, 2017
PublishedFeb 16, 2017
Warriors Trained4391
Total Skips108
Total Code Submissions8952
Total Times Completed2409
C# Completions260
Python Completions1017
Rust Completions133
JavaScript Completions550
C Completions197
Prolog Completions17
Haskell Completions51
Ruby Completions63
C++ Completions297
Nim Completions13
COBOL Completions4
Total Stars40
% of votes with a positive feedback rating94% of 432
Total "Very Satisfied" Votes384
Total "Somewhat Satisfied" Votes40
Total "Not Satisfied" Votes8
Total Rank Assessments12
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Anarki Avatar
  • anter69 Avatar
  • smile67 Avatar
  • imjasonmiller Avatar
  • JohanWiltink Avatar
  • B1ts Avatar
  • rowcased Avatar
  • metagn Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
  • username0 Avatar
  • yuskivpm Avatar
  • akar-0 Avatar
  • dimitridev Avatar
  • Just4FunCoder Avatar
  • KayleighWasTaken Avatar
Ad