Example #1
0
        internal static IEnumerable <string> OrderByLength(string input, bool verbose, string delimiter)
        {
            var text = InputStringGetter.GetInputString(input);

            var words = text.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var word in words.OrderByDescending(w => w.Length))
            {
                yield return(word);
            }
        }
Example #2
0
        internal static IEnumerable <string> ReverseEach(string input, bool verbose, string delimiter)
        {
            var text = InputStringGetter.GetInputString(input);

            var words = text.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var word in words)
            {
                yield return(Reverse(word));
            }
        }
        private static IEnumerable <string> Analyze(string input, bool verbose, string delimiter, Func <string, bool> matcher)
        {
            var text = InputStringGetter.GetInputString(input);

            var words = text.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);

            var ret = new List <String>();

            foreach (var word in words)
            {
                if (matcher(word))
                {
                    ret.Add(word);
                }
            }

            return(ret);
        }
        internal static IEnumerable <string> GetCharacterCounts(string input, bool verbose, string delimiter)
        {
            var counts = new ConcurrentDictionary <char, int>();

            var text = InputStringGetter.GetInputString(input);

            var words = text.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var word in words)
            {
                word.ForEach(c => counts.AddOrUpdate(c, 1, (id, count) => count + 1));
            }

            foreach (var count in counts.OrderBy(c => c.Key, OrderByDirection.Ascending))
            {
                yield return($"{count.Key}: {count.Value}");
            }
        }