using System; class Test { static string[] n = { "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE" }; static string DeCrypt(string s) { string a = s, d = ""; int x = 1, p, i; while (a != "") { a = s; d = ""; for (i = x; i <= 9 && a!=""; i++) { foreach (char c in n[i - 1]) { p = a.IndexOf(c); if (p >= 0) a = a.Remove(p, 1); else { a = "!"; x++; break; } } if (a == "!") { break; } d += i; } } return d; } public static void Main() { Console.WriteLine(DeCrypt("WNTEOO")); Console.WriteLine(DeCrypt("HSISIIXEEGEEVNNNT")); } }