Can you simply explain what they want from me in coderbyte challenge? I am really new and stuck
H Distance
Have the function HDistance(strArr) take the array of strings stored in strArr, which will only contain two strings of equal length and return the number of characters at each position that are different between them. For example: if strArr is [“house”, “hours”] then your program should return 2. The string will always be of equal length and will only contain lowercase characters from the alphabet and numbers.
Hi thank you! Sorry I submitted the one I posted question about already. but here is the new one I am doing on H Distance if you can help pls Coderbyte | The #1 Coding Assessment Platform
Did anyone solve this? No matter what I put it either comes up with the words I used as examples or the number 0 or 1 depending on how I change the code
It may be easier to help if you share your code.
The return should not be in the loop.
def HDistance(strArr):
length = min(len(strArr[0]), len(strArr[1]))
h = 0
for j in range(length):
if (strArr[0][j] != strArr[1][j]):
h += 1
return h
print(HDistance(["10011", "10100"]))
print(HDistance(["abcdef", "defabc"]))
print(HDistance(["house", "hours"]))