Ejemplo n.º 1
0
        private static void AssertMedian(int assert, IEnumerable <int> items)
        {
            var median = new MedianAlgorithm();

            items.ToList().ForEach(x => { median.Add(x); });
            Assert.AreEqual(assert, median.Median());
        }
        public void Assignment()
        {
            const int capacity = 10000;

            var parser = new FileParser();
            var numbers = parser.Read("Median.txt")
                .Select(i => (int)i)
                .ToArray();

            var algorithm = new MedianAlgorithm();
            long cum = numbers.Select(n => algorithm.Add(n)).Aggregate<int, long>(0, (current, median) => current + median);

            var result = cum%capacity;
            Console.WriteLine("The medians answer: {0}", result);
        }
Ejemplo n.º 3
0
        public void Assignment()
        {
            const int capacity = 10000;

            var parser  = new FileParser();
            var numbers = parser.Read("Median.txt")
                          .Select(i => (int)i)
                          .ToArray();

            var  algorithm = new MedianAlgorithm();
            long cum       = numbers.Select(n => algorithm.Add(n)).Aggregate <int, long>(0, (current, median) => current + median);

            var result = cum % capacity;

            Console.WriteLine("The medians answer: {0}", result);
        }
 private static void AssertMedian(int assert, IEnumerable<int> items)
 {
     var median = new MedianAlgorithm();
     items.ToList().ForEach(x => { median.Add(x); });
     Assert.AreEqual(assert, median.Median());
 }