mirror of
https://github.com/Xevion/exercism.git
synced 2025-12-16 02:11:44 -06:00
PowerShell - hamming
This commit is contained in:
10
powershell/hamming/HammingDifference.ps1
Normal file
10
powershell/hamming/HammingDifference.ps1
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user