mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
29 lines
745 B
C#
29 lines
745 B
C#
using System;
|
|
|
|
public static class Kata
|
|
{
|
|
public static string Likes(string[] name)
|
|
{
|
|
var prefix = "";
|
|
switch (name.Length) {
|
|
case 0:
|
|
prefix = "no one";
|
|
break;
|
|
case 1:
|
|
prefix = name[0];
|
|
break;
|
|
case 2:
|
|
prefix = String.Join(" and ", name);
|
|
break;
|
|
case 3:
|
|
prefix = String.Join(", ", name, 0, 2) + " and " + name[2];
|
|
break;
|
|
default:
|
|
prefix = String.Join(", ", name, 0, 2) + String.Format(" and {0} others", name.Length - 2);
|
|
break;
|
|
}
|
|
|
|
if (name.Length <= 1) return prefix + " likes this";
|
|
else return prefix + " like this";
|
|
}
|
|
}
|