using System.Collections.Generic;
public static void Main()
var time = "1 800 RED CrOSS";
Console.WriteLine(TranslateVanityNumbers(time));
Console.WriteLine("1-800-733-276");
public static string TranslateVanityNumbers(string phoneNumber)
IEnumerable<char> takeNthDigits(IEnumerable<char> source, int limit)
return source.Select(it => (it, count += char.IsLetterOrDigit(it) ? 1 : 0)).TakeWhile(p => p.Item2 <= limit).Select(x => x.it);
return string.Concat(takeNthDigits(phoneNumber, 10).Select(c => char.ToUpper(c) switch
'A' or 'B' or 'C' => '2',
'E' or 'D' or 'F' => '3',
'G' or 'H' or 'I' => '4',
'J' or 'K' or 'L' => '5',
'M' or 'N' or 'O' => '6',
'T' or 'U' or 'V' => '8',
'X' or 'Y' or 'Z' => '9',