You are viewing a single comment's thread. Return to all comments →
I am kinda having trouble understanding the count/2 part. An explanation would be good. Thanks.
This method counts for differences on both strings, so the answer needs to be reduced by half since the question asks how many times ONE string needs to be modified to match the other. For example, with string "aaabbb", this method concludes that "aaa" doesn't match "bbb" and that "bbb" doesn't match "aaa", implying that 6 letters need to be modified for them to equal somehow (i.e. cccccc). However we just need one string to transform into another, so really only 3 letters need to be modified (i.e. "aaa" from first string becomes "bbb", thus matching the second).
Instead of checking both first and second string. I checked only the first string and then didn't multiply the count by half.