My attempts at exercism.org
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 20 lines 404 B view raw
1<?php 2 3declare(strict_types=1); 4 5function distance(string $strandA, string $strandB): int 6{ 7 if (strlen($strandA) != strlen($strandB)) { 8 throw new InvalidArgumentException("strands must be of equal length"); 9 } 10 11 $distance = 0; 12 13 for ($i = 0; $i < strlen($strandA); $i++) { 14 if ($strandA[$i] != $strandB[$i]) { 15 $distance++; 16 } 17 } 18 19 return $distance; 20}