Sha256: 44cd44aab1bd8ee11847d2759e4ae2ce7b76f705dc8680631c5d94f463328042

Contents?: true

Size: 351 Bytes

Versions: 396

Compression:

Stored size: 351 Bytes

Contents

<?php

/**
 * @param string $a
 * @param string $b
 * @return int distance
 */
function distance($a, $b)
{
    if (strlen($a) !== strlen($b)) {
        throw new InvalidArgumentException('DNA strands must be of equal length.');
    }

    return count(
        array_diff_assoc(
            str_split($a),
            str_split($b)
        )
    );
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/php/exercises/hamming/example.php
trackler-2.2.1.179 tracks/php/exercises/hamming/example.php
trackler-2.2.1.178 tracks/php/exercises/hamming/example.php
trackler-2.2.1.177 tracks/php/exercises/hamming/example.php
trackler-2.2.1.176 tracks/php/exercises/hamming/example.php
trackler-2.2.1.175 tracks/php/exercises/hamming/example.php
trackler-2.2.1.174 tracks/php/exercises/hamming/example.php
trackler-2.2.1.173 tracks/php/exercises/hamming/example.php
trackler-2.2.1.172 tracks/php/exercises/hamming/example.php
trackler-2.2.1.171 tracks/php/exercises/hamming/example.php
trackler-2.2.1.170 tracks/php/exercises/hamming/example.php
trackler-2.2.1.169 tracks/php/exercises/hamming/example.php
trackler-2.2.1.167 tracks/php/exercises/hamming/example.php
trackler-2.2.1.166 tracks/php/exercises/hamming/example.php
trackler-2.2.1.165 tracks/php/exercises/hamming/example.php
trackler-2.2.1.164 tracks/php/exercises/hamming/example.php
trackler-2.2.1.163 tracks/php/exercises/hamming/example.php
trackler-2.2.1.162 tracks/php/exercises/hamming/example.php
trackler-2.2.1.161 tracks/php/exercises/hamming/example.php
trackler-2.2.1.160 tracks/php/exercises/hamming/example.php