Not knowing what a Hamming Distance is I followed the link to http://en.wikipedia.org/wiki/Hamming_distance and found that it is a measure of the difference between two strings i.e. how many substitutions are required to turn one string into another.

We can find the Hamming Distance as follows

001 002 003 004 005

param([string]$str1="stone",[string]$str2="roses")$hd=0if($str1.length-ne$str2.length){Throw"Strings are not the same length"}for($i=0;$i-le($str1.length-1);$i++){if($str1.SubString($i,1)-ne$str2.SubString($i,1)){$hd++}}Write-Host"Hamming Distance for $str1 and $str2 is $hd"

Input a couple of strings, check they are the same length and then compare on a character by character basis.