using System.Collections.Generic;
static string shortenString(string input) {
var word = new List<char>();
var processedChars = new List<char>();
processedChars.AddRange(processWord(word));
if(c.Equals(input.Last()))
processedChars.AddRange(processWord(word));
return new string(processedChars.ToArray());
static bool isLetter(char c)
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
static List<char> processWord(List<char> chars)
return new List<char>{chars.ElementAt(0), '0', chars.ElementAt(1)};
return new List<char>{chars.ElementAt(0), '0', chars.ElementAt(0)};
var middlePortion = new List<char>();
var newWord = new List<char>();
newWord.Add(chars.ElementAt(0));
for(int i = 1; chars.Count()-1 > i; i++)
middlePortion.Add(chars.ElementAt(i));
var uniqueChars = new List<char>();
uniqueChars.Add(middlePortion.ElementAt(0));
foreach(char middleChar in middlePortion){
for(var i = 0; uniqueChars.Count() > i; i++){
if(middleChar == uniqueChars.ElementAt(i)){
if(i == uniqueChars.Count()-1){
uniqueChars.Add(middleChar);
newWord.AddRange(uniqueChars.Count().ToString().ToCharArray());
newWord.Add(chars.ElementAt(chars.Count()-1));
public static void Main()
Console.WriteLine(shortenString("Fun to eat!"));