Example #1
0
        public static void Main()
        {
            string inputText = "ыуао ра шц цшукао экмоы о324 243к23ы";
            string message   = Refactored.CalculateLetterCount(inputText);

            Console.WriteLine(message);
            Console.ReadKey();
        }
Example #2
0
        private static string CalculateLetterCount(string text)
        {
            StringBuilder sb       = new StringBuilder();
            string        template = "letter:{0}; count:{1}";

            for (int i = 0; i < text.Length; i++)
            {
                char current = text[i];
                if (Refactored.GetPreviousIndex(text, current, i - 1) == -1)
                {
                    int count = Refactored.GetCount(text, current, i + 1);
                    sb.AppendLine(string.Format(template, current, count));
                }
            }
            return(sb.ToString().TrimEnd(Environment.NewLine.ToCharArray()));
        }