Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active August 11, 2020 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/63ee2d1ffb67c6f3632c870bd3d4fbf7 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/63ee2d1ffb67c6f3632c870bd3d4fbf7 to your computer and use it in GitHub Desktop.
Just PHP FUN 073.
<?php
# https://www.codewars.com/kata/59c633e7dcc4053512000073 Consonant value.
function solve($s) {
$a = array_map( function($x){
if(preg_match('/[aeiou]/',$x)){
return 0;
}
return ord($x) + 1 - ord('a');
}
,str_split($s));
$max = 0; $sum = 0;
foreach($a as $v){
$sum = $v === 0 ? 0 : $sum + $v;
if($max < $sum) $max = $sum;
}
return $max;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment