Skip to content

Commit

Permalink
Update compare-strings-hamming-distance.php
Browse files Browse the repository at this point in the history
got rid of 0 as min value as it is pointless to do -0 twice
  • Loading branch information
akosnikhazy authored Oct 2, 2024
1 parent 8f14c88 commit 23e3989
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compare-strings-hamming-distance.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function textToBin($str)

}

if($normalize) return (1-0)/(strlen($bins[0]) - 0) * ($hammingDistance + (strlen($bins[0])-strlen($bins[1])) - strlen($bins[0])) + 1;
if($normalize) return 1/(strlen($bins[0])) * ($hammingDistance + (strlen($bins[0])-strlen($bins[1])) - strlen($bins[0])) + 1;

// add the length difference between the two string, as every non existent
// bit is different than any existing one.
Expand Down

0 comments on commit 23e3989

Please sign in to comment.