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.159 tracks/php/exercises/hamming/example.php
trackler-2.2.1.158 tracks/php/exercises/hamming/example.php
trackler-2.2.1.157 tracks/php/exercises/hamming/example.php
trackler-2.2.1.156 tracks/php/exercises/hamming/example.php
trackler-2.2.1.155 tracks/php/exercises/hamming/example.php
trackler-2.2.1.154 tracks/php/exercises/hamming/example.php
trackler-2.2.1.153 tracks/php/exercises/hamming/example.php
trackler-2.2.1.152 tracks/php/exercises/hamming/example.php
trackler-2.2.1.151 tracks/php/exercises/hamming/example.php
trackler-2.2.1.150 tracks/php/exercises/hamming/example.php
trackler-2.2.1.149 tracks/php/exercises/hamming/example.php
trackler-2.2.1.148 tracks/php/exercises/hamming/example.php
trackler-2.2.1.147 tracks/php/exercises/hamming/example.php
trackler-2.2.1.146 tracks/php/exercises/hamming/example.php
trackler-2.2.1.145 tracks/php/exercises/hamming/example.php
trackler-2.2.1.144 tracks/php/exercises/hamming/example.php
trackler-2.2.1.143 tracks/php/exercises/hamming/example.php
trackler-2.2.1.142 tracks/php/exercises/hamming/example.php
trackler-2.2.1.141 tracks/php/exercises/hamming/example.php
trackler-2.2.1.140 tracks/php/exercises/hamming/example.php