Sha256: e6fa0d812789d2671a45eb4c5aa4bb9235e1b4db6cfa8f2ad4c3a3b9958342d1

Contents?: true

Size: 360 Bytes

Versions: 293

Compression:

Stored size: 360 Bytes

Contents

package Example;

use strict;
use warnings;

use Carp;

sub compute {
    my ($strand_a, $strand_b) = @_;

    croak "DNA strands must be of equal length"
        unless length $strand_a == length $strand_b;

    my $distance = $strand_a ^ $strand_b;
    $distance =~ s/\0//g;

    return (length $distance) - abs(length($strand_a) - length($strand_b));
}

1;

Version data entries

293 entries across 293 versions & 1 rubygems

Version Path
trackler-2.2.1.45 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.44 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.43 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.42 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.41 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.40 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.39 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.38 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.37 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.36 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.35 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.34 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.33 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.32 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.31 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.30 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.29 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.28 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.27 tracks/perl5/exercises/hamming/Example.pm
trackler-2.2.1.26 tracks/perl5/exercises/hamming/Example.pm