tracks/perl6/exercises/hamming/Example.pm6 in trackler-2.2.1.65 vs tracks/perl6/exercises/hamming/Example.pm6 in trackler-2.2.1.66
- old
+ new
@@ -1,6 +1,7 @@
-unit module Hamming:ver<1>;
+unit module Hamming:ver<2>;
-sub hamming-distance ( Str:D $strand1, Str:D $strand2 --> Int:D ) is export {
- die ‘left and right strands must be of equal length’ if $strand1.chars ≠ $strand2.chars;
- ($strand1.comb Zne $strand2.comb).sum
+sub hamming-distance (
+ +@strands where { .elems == 2 && [==] $_».chars } --> Int:D
+) is export {
+ sum [Zne] @strands».comb
}