id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > hamming
prev  |  next  |  chance

Hamming distance, de ned to be the number of bit positions that are different between two bit strings, is used to measure the error that is introduced when data is sent over a network. For example, suppose we sent the bit sequence 011100110001 over a network, but the destination received 011000110101 instead. To measure the transmission error, we can find the Hamming distance between the two sequences by lining them up as follows: Sent: 011100110001 Received: 011000110101 Since the bit sequences are different in two positions, the Hamming distance is 2. Write a function hamming(bits1, bits2) that returns the Hamming distance between the two given bit strings. Do not assume that the two strings have the same length.


hamming('001010', '000000') → 2
hamming('010111001', '10111100100') → 5
hamming('010101', '101010') → 6

...Save, Compile, Run (ctrl-enter)

def hamming(bits1, bits2):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy