6 kyu

Simple Fun #141: Hamming Distance

747 of 1,671myjinxin2015

Description:

Task

The hamming distance between a pair of numbers is the number of binary bits that differ in their binary notation.

Example

For a = 25, b = 87, the result should be 4

25: 00011001
87: 01010111

The hamming distance between these two would be 4 ( the 2nd, 5th, 6th, 7th bit ).

Input/Output

  • [input] integer a

First Number. 1 <= a <= 2^20

  • [input] integer b

Second Number. 1 <= b <= 2^20

  • [output] an integer

Hamming Distance

Puzzles

Stats:

CreatedFeb 17, 2017
PublishedFeb 17, 2017
Warriors Trained2661
Total Skips39
Total Code Submissions4193
Total Times Completed1671
JavaScript Completions476
C# Completions147
Python Completions747
Ruby Completions63
C Completions170
C++ Completions170
COBOL Completions7
Factor Completions9
Haskell Completions31
λ Calculus Completions9
Total Stars41
% of votes with a positive feedback rating94% of 350
Total "Very Satisfied" Votes311
Total "Somewhat Satisfied" Votes35
Total "Not Satisfied" Votes4
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • JohanWiltink Avatar
  • tachyonlabs Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • akar-0 Avatar
  • ilash Avatar
  • Kacarott Avatar
  • dfhwze Avatar
  • saudiGuy Avatar
Ad