コード例 #1
0
        private static void writeRecordsInFilesReview()
        {
            NumberSequenceScanner scanner = new TopToBottomNumberSequenceScanner();

            List <string> greatestNeighboringSequence = new List <string>();
            var           currentData = DataHelper.GetDataPoints();
            var           itemsScannedFromTopToBottom = scanner.GetScannedNumberSequence();
            string        topToBottom = getSortedResults(itemsScannedFromTopToBottom);


            scanner = new LeftToRightNumberSequenceScanner();
            var    itemsScannedFromLeftToRight = scanner.GetScannedNumberSequence();
            string leftToRight = getSortedResults(itemsScannedFromLeftToRight);

            scanner = new TopToBottmonDiagnoalLeftToRightScanner();

            var itemsScannedDiagonalFromLeftToRight = scanner.GetScannedNumberSequence();

            string topToBottomDiagonal = getSortedResults(itemsScannedDiagonalFromLeftToRight);


            scanner = new TopToBottomDiagnoalRightToLeftScanner();

            var itemScannedDiagonalFromRightToLeft = scanner.GetScannedNumberSequence();

            string topToBottomDiagonalGoingRightToLeft = getSortedResults(itemScannedDiagonalFromRightToLeft);


            print(topToBottom, leftToRight, topToBottomDiagonal, topToBottomDiagonalGoingRightToLeft);
        }
コード例 #2
0
        private static void findTheGreatestNeighbouringSequenceInEntireNumberListing()
        {
            NumberSequenceScanner scanner = new TopToBottomNumberSequenceScanner();
            List <string>         greatestNeighboringSequence = new List <string>();
            var itemsScannedFromTopToBottom = scanner.GetScannedNumberSequence();

            scanner = new LeftToRightNumberSequenceScanner();
            var itemsScannedFromLeftToRight = scanner.GetScannedNumberSequence();

            scanner = new TopToBottmonDiagnoalLeftToRightScanner();

            var itemsScannedDiagonalFromLeftToRight = scanner.GetScannedNumberSequence();

            scanner = new TopToBottomDiagnoalRightToLeftScanner();

            var itemScannedDiagonalFromRightToLeft = scanner.GetScannedNumberSequence();

            var greatestProductFinder = new GreatestProductFinders();

            var itemsScannedFromTopToBottomHighest         = greatestProductFinder.GetProductComponent(itemsScannedFromTopToBottom);
            var itemsScannedFromLeftToRightHighest         = greatestProductFinder.GetProductComponent(itemsScannedFromLeftToRight);
            var itemsScannedDiagonalFromLeftToRightHighest = greatestProductFinder.GetProductComponent(itemsScannedDiagonalFromLeftToRight);
            var itemScannedDiagonalFromRightToLeftHighest  = greatestProductFinder.GetProductComponent(itemScannedDiagonalFromRightToLeft);


            List <ProductComponent> components = new List <ProductComponent>();

            components.Add(itemsScannedFromTopToBottomHighest);
            components.Add(itemsScannedFromLeftToRightHighest);
            components.Add(itemsScannedDiagonalFromLeftToRightHighest);
            components.Add(itemScannedDiagonalFromRightToLeftHighest);



            // sort it

            components.Sort((x, y) => { return(y.Product.CompareTo(x.Product)); });

            // print on console

            //foreach (var component in components)
            //{

            //    Console.WriteLine("Higest Components from different types of scanner : " + component.Component + " Product : =" + component.Product);
            //}



            var highestComponent = greatestProductFinder.GetProductComponent(components);


            Console.WriteLine("Highest Neighbouring sequence number is : ");
            Console.WriteLine("[" + highestComponent.Component.Substring(0, highestComponent.Component.Length - 1) + "]=" + highestComponent.Product);

            Console.ReadLine();
        }