- https://www.codewars.com/kata/585d8c8a28bc7403ea0000c3 Find the unique string.
Started at 22:59 21.09.2020 Monday Sep.
Finished at 23:19 21.09.2020 Monday Sep. (0hrs 20minutes)
<?php | |
# https://www.codewars.com/kata/585d8c8a28bc7403ea0000c3 Find the unique string. | |
function find_uniq($a) { | |
$hash = []; | |
foreach($a as $v){ | |
$h = str_split(preg_replace('/\s/','',strtolower($v))); | |
sort($h); | |
$h = implode(array_unique($h)); | |
if(!isset($hash[$h])){ | |
$hash[$h] = []; | |
} | |
array_push($hash[$h],$v); | |
} | |
foreach($hash as $v) if(1 == count($v)) return $v[0]; | |
throw new Exception('No answer.'); | |
} |
Started at 22:59 21.09.2020 Monday Sep.
Finished at 23:19 21.09.2020 Monday Sep. (0hrs 20minutes)