PowerShell - hamming

This commit is contained in:
Xevion
2021-11-26 02:29:57 -06:00
parent c90524ae8e
commit 596aa4f029
7 changed files with 201 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
function Get-HammingDifference([string]$A, [string]$B) {
if ($A.Length -ne $B.Length) {
Throw("Left and right strands must be of equal length.")
}
[int] $hamming = 0
0..$A.Length | % { if ($A[$_] -ne $B[$_]) { $hamming++ } }
return $hamming
}