public void Run()
 {
     AssortedMethods.PrintLine('-', "Sort_GroupWordsByAnagram_UsingCustomAnagramComparator");
     string[] array = { "apple", "banana", "carrot", "ele", "duck", "papel", "tarroc", "cudk", "eel", "lee" };
     Sort_GroupWordsByAnagram_UsingCustomAnagramComparator(array);
     AssortedMethods.PrintLine('-', "Sort_GroupWordsByAnagram_UsingDictionary");
     string[] array2 = { "apple", "banana", "carrot", "ele", "duck", "papel", "tarroc", "cudk", "eel", "lee" };
     Sort_GroupWordsByAnagram_UsingDictionary(array2);
 }
            public void Run()
            {
                int[] nthCounts = new int[] { 1, 3 }; //, 2, 9, 10, 11,12
                nthCounts.Print("Get Positions:");
                var head = GetLinkedListSingly_Serial(0, 10);

                head.PrintForward("\nLink List:");

                foreach (int nth in nthCounts)
                {
                    int i = 0;
                    Console.WriteLine($"NthToLast_1_Recurssive_InternalCounter: {NthToLast_1_Recurssive_InternalCounter(head, nth)}");
                    AssortedMethods.PrintLine('-');
                    Console.WriteLine($"NthToLast_2_Recurssive_ExternalCounter: {NthToLast_2_Recurssive_ExternalCounter(head, nth, ref i).NodeValue()}");
                    AssortedMethods.PrintLine('-');
                    Console.WriteLine($"NthToLast_3_Recurssive_ExternalCounterAndNode{NthToLast_3_Recurssive_ExternalCounterAndNode(head, nth).NodeValue()}");
                    AssortedMethods.PrintLine('-');
                    Console.WriteLine($"NthToLast_4_Iterative_TwoPointers{NthToLast_4_Iterative_TwoPointers(head, nth).NodeValue()}");
                    AssortedMethods.PrintLine('=');
                }
            }
예제 #3
0
        public static void PrintBinaryToString_Run()
        {
            double number = 0.125;
            int    bits   = 32;//try for both 32 and 64

            Console.WriteLine($"double number ='{number}' Binary Representation ='{ PrintBinaryToString_UsingMultiplicationBy2(number, bits)}' ");
            Console.WriteLine($"double number ='{number}' Binary Representation ='{ PrintBinaryToString_UsingProgressveFraction(number, bits)}' ");
            AssortedMethods.PrintLine('=', "Print for 0-999 only if no error");

            for (var i = 0; i < 1000; i++)
            {
                var num     = i / 1000.0;
                var binary  = PrintBinaryToString_UsingMultiplicationBy2(num, bits);
                var binary2 = PrintBinaryToString_UsingProgressveFraction(num, bits);

                if (!binary.Contains("ERROR") || !binary2.Contains("ERROR"))
                {
                    Console.WriteLine($"number={num} : " +
                                      $"PrintBinaryToString_UsingMultiplicationBy2={binary} " +
                                      $"PrintBinaryToString_UsingProgressveFraction {binary2}");
                    AssortedMethods.PrintLine('-');
                }
            }
        }