- https://www.codewars.com/kata/57eb8fcdf670e99d9b000272 Highest Scoring Word.
Started at 22:39 29.09.2020 Tuesday Sep.
Finished at 22:47 29.09.2020 Tuesday Sep. (0hrs 8minutes)
<?php | |
# https://www.codewars.com/kata/57eb8fcdf670e99d9b000272 Highest Scoring Word. | |
function high($x) { | |
$x = array_map(function($x){ return [$x,the_sum($x)];},explode(" ",$x)); | |
$max = ["",0]; | |
foreach($x as $pair) if($pair[1] > $max[1]) $max = $pair; | |
return $max[0]; | |
} | |
function the_sum($str){ | |
$sum = 0; | |
for($i = 0; $i < strlen($str) ; $i+=1) $sum += 1 + ord($str[$i]) - ord("a"); | |
return $sum; | |
} |
Started at 22:39 29.09.2020 Tuesday Sep.
Finished at 22:47 29.09.2020 Tuesday Sep. (0hrs 8minutes)