I voted for clever, because this scales with the interval lengths, not the count of the intervals. So if you want to have large intervals, this can be slow: echo sum_intervals([[0, 40000000]]);
I think it's easier to find ending Exclamation marks themselves using preg_match rather than remove all symbols except ending Exclamation marks using preg_replace
I think this solution is fit perfect for given description. The only one thing which I would correct is implode($arr). There is no need in delimiter at all.
Good job, I voted for clever too.
I like this with recursivity
I voted for clever, because this scales with the interval lengths, not the count of the intervals. So if you want to have large intervals, this can be slow:
echo sum_intervals([[0, 40000000]]);
Yet readability is A+ :)
wow, this is another level. it's crazy to think the amount of "ifs" that I used and this could have been solved more simply
wtf i did the same at first, but it didnt work :(
I think it's easier to find ending Exclamation marks themselves using preg_match rather than remove all symbols except ending Exclamation marks using preg_replace
The rating of this solution shows how the developers tend to ignore the description in favor of a solution with less lines.
I think this solution is fit perfect for given description. The only one thing which I would correct is implode($arr). There is no need in delimiter at all.
Unnecessary 'else' in code.
if (blabla){
return 'blablabla';
}
return 'another blabla';
I need to utilize ternary operators more. Thanks for this solution!