- https://www.codewars.com/kata/5266876b8f4bf2da9b000362 Who likes it?
Started at 20:59 24.09.2020 Thursday Sep.
Finished at 21:13 24.09.2020 Thursday Sep. (0hrs 14minutes)
Started at 20:59 24.09.2020 Thursday Sep.
Finished at 21:13 24.09.2020 Thursday Sep. (0hrs 14minutes)
<?php | |
# https://www.codewars.com/kata/5266876b8f4bf2da9b000362 Who likes it? | |
function likes( $names ) { | |
$size = count($names); | |
if(0 == $size) return "no one likes this"; | |
if(1 == $size) return sprintf("%s likes this",$names[0]); | |
if(2 == $size) return sprintf("%s and %s like this",$names[0],$names[1]); | |
if(3 == $size) return sprintf("%s, %s and %s like this",$names[0],$names[1],$names[2]); | |
return sprintf("%s, %s and %s others like this",$names[0],$names[1],$size-2); | |
} |