mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
32 lines
647 B
C#
32 lines
647 B
C#
using System;
|
|
|
|
public class Abbreviator
|
|
{
|
|
public static string Abbreviate(string input)
|
|
{
|
|
string result = "", temp = "";
|
|
|
|
for (int i = 0; i < input.Length; i++)
|
|
{
|
|
if (Char.IsLetter(input[i]))
|
|
temp += input[i];
|
|
else
|
|
{
|
|
if (temp.Length <= 3) result += temp + input[i];
|
|
else
|
|
{
|
|
result += temp[0] + (temp.Length - 2).ToString() + temp[temp.Length - 1] + input[i];
|
|
}
|
|
temp = "";
|
|
}
|
|
}
|
|
|
|
if (temp.Length <= 3) result += temp;
|
|
else
|
|
{
|
|
result += temp[0] + (temp.Length - 2).ToString() + temp[temp.Length - 1];
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|