7 kyu

Delta Bits

697 of 3,375ykagan

Description:

Complete the function to determine the number of bits required to convert integer A to integer B (where A and B >= 0)

The upper limit for A and B is 216, int.MaxValue or similar.

For example, you can change 31 to 14 by flipping the 4th and 0th bit:

 31  0 0 0 1 1 1 1 1
 14  0 0 0 0 1 1 1 0
---  ---------------
bit  7 6 5 4 3 2 1 0

Thus 31 and 14 should return 2.

Bits
Binary
Algorithms

Similar Kata:

Stats:

CreatedMay 31, 2014
PublishedMay 31, 2014
Warriors Trained6199
Total Skips1017
Total Code Submissions14906
Total Times Completed3375
JavaScript Completions815
Ruby Completions383
CoffeeScript Completions37
Java Completions1238
C# Completions159
Python Completions697
NASM Completions31
C Completions184
Rust Completions33
Haskell Completions12
Total Stars73
% of votes with a positive feedback rating92% of 561
Total "Very Satisfied" Votes476
Total "Somewhat Satisfied" Votes75
Total "Not Satisfied" Votes10
Ad
Contributors
  • ykagan Avatar
  • jhoffner Avatar
  • hbakhtiyor Avatar
  • jamiely Avatar
  • pablo.varela Avatar
  • anter69 Avatar
  • nguyen_v Avatar
  • JohanWiltink Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • akar-0 Avatar
  • saudiGuy Avatar
Ad