Example #1
0
        public static void Main()
        {
            new[] { 3, 4, 4, 2, 3, 3, 4, 3, 2 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();
            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidIntegerTo1000);

            var numbersCount = inputNumbers.GetOccurenceCount();
            numbersCount.ForEach(x => Console.WriteLine("{0} -> {1} times", x.Key, x.Value));
        }
Example #2
0
        public static void Main()
        {
            new[] { -2, -2, 0, 3, 4, 5, 6, 7, 8, 12 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();

            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidInteger);
            var reversedNumbers = inputNumbers.StackReverse();
            reversedNumbers.ForEach(x => Console.Write("{0}  ", x));
        }
Example #3
0
        public static void Main()
        {
            new[] { 1, 2, 3, 4, 5 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();

            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidPositiveInteger);
            Console.WriteLine(inputNumbers.Sum());
            Console.WriteLine(inputNumbers.Average());
        }
Example #4
0
        public static void Main()
        {
            new[] { 1, 0, -10, 4, -5, 3, 7, 6, 8, -8, -2, -4, 5 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();
            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidInteger);

            var onlyPositive = inputNumbers.GetOnlyPositiveNumbers();
            Console.WriteLine(string.Join(" ", onlyPositive));
        }
Example #5
0
        public static void Main()
        {
            new[] { 4, 2, 2, 5, 2, 3, 2, 3, 1, 5, 2 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();
            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidInteger);

            var onlyEvenOccurences = inputNumbers.RemoveOddOccurences();
            Console.WriteLine(string.Join(" ", onlyEvenOccurences));
        }
Example #6
0
        public static void Main()
        {
            new[] { 9, 5, 7, 3, 1, 0, 5, 2, 8, 6, -2, -10, 0, 0 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();

            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidInteger);
            inputNumbers.OrderBy(x => x)
                .ForEach(x => Console.Write("{0}  ", x));
        }
Example #7
0
        public static void Main()
        {
            new[] { 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();
            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidInteger);

            var longestSubsequence = inputNumbers.GetLongestEqualSubsequence();
            Console.WriteLine(string.Join(" ", longestSubsequence));
        }
Example #8
0
        public static void Main()
        {
            new[] { 2, 2, 3, 3, 2, 3, 4, 3, 3 }.CopyArrayToClipboard();
            Console.WriteLine("The sample input is copied to Your clipboard - just paste it in the console.");

            var predicates = new PredicateProvider();
            var reader = new Reader();
            var inputNumbers = reader.ReadList(predicates.ShouldStopReading, predicates.IsValidInteger);

            var majorant = inputNumbers.GetMajorant();

            Console.WriteLine("Majorant: " + majorant);
        }