Exemple #1
0
        static void RunQueuesAndStacks()
        {
            var input             = Console.ReadLine();
            var coderInThirtyDays = new CoderInThirtyDays();

            Console.WriteLine(coderInThirtyDays.IsPalindrome(input));
        }
Exemple #2
0
        static void RunBinaryNumbers()
        {
            var number            = Convert.ToInt32(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();

            Console.WriteLine(coderInThirtyDays.CountConsecutiveOnes(number));
        }
Exemple #3
0
        static void RunLoops()
        {
            var number            = Convert.ToInt32(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();

            coderInThirtyDays.PrintMultiplies(number);
        }
Exemple #4
0
        static void RunIntroToConditionalStatements()
        {
            var number            = Convert.ToInt32(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();

            Console.WriteLine(coderInThirtyDays.CalculateWeirdness(number));
        }
Exemple #5
0
        static void RunExceptionsStringToInteger()
        {
            var    input             = Console.ReadLine();
            var    coderInThirtyDays = new CoderInThirtyDays();
            Object result            = coderInThirtyDays.ConvertStringToInteger(input);

            Console.WriteLine(result);
        }
Exemple #6
0
        static void RunRecursion3()
        {
            var number            = Convert.ToInt32(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();
            int result            = coderInThirtyDays.CalculateFactorial(number);

            Console.WriteLine(result);
        }
Exemple #7
0
        static void RunArrays()
        {
            var arrayLength = Convert.ToInt32(Console.ReadLine());

            int[] numberArray = Array.ConvertAll(Console.ReadLine().Split(' '), tempArray => Convert.ToInt32(tempArray));

            var coderInThirtyDays = new CoderInThirtyDays();

            Console.WriteLine(coderInThirtyDays.ReverseArray(numberArray));
        }
Exemple #8
0
        static void RunOperators()
        {
            var mealCost = Convert.ToDouble(Console.ReadLine());

            var tipPercent = Convert.ToInt32(Console.ReadLine());

            var taxPercent        = Convert.ToInt32(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();

            coderInThirtyDays.CalculateTotalCost(mealCost, tipPercent, taxPercent);
        }
Exemple #9
0
        static void RunRunningTimeAndComplexity()
        {
            var testsAmount       = Int32.Parse(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();

            for (var i = 0; i < testsAmount; i++)
            {
                var number = Int32.Parse(Console.ReadLine());
                Console.WriteLine(coderInThirtyDays.IsPrimeNumber(number));
            }
        }
Exemple #10
0
        static void RunNestedLogic()
        {
            var returnedDateString = Console.ReadLine();
            var expectedDateString = Console.ReadLine();

            String[] returnedDate      = returnedDateString.Split(' ');
            String[] expectedDate      = expectedDateString.Split(' ');
            var      coderInThirtyDays = new CoderInThirtyDays();

            Console.WriteLine(coderInThirtyDays.CalculateFineForLibraryBook(Int32.Parse(returnedDate[0]), Int32.Parse(returnedDate[1]), Int32.Parse(returnedDate[2]),
                                                                            Int32.Parse(expectedDate[0]), Int32.Parse(expectedDate[1]), Int32.Parse(expectedDate[2])));
        }
Exemple #11
0
        static void RunLinkedList()
        {
            Node head              = null;
            var  testsAmount       = Int32.Parse(Console.ReadLine());
            var  coderInThirtyDays = new CoderInThirtyDays();

            while (testsAmount-- > 0)
            {
                var data = Int32.Parse(Console.ReadLine());
                head = coderInThirtyDays.InsertNodeToLinkedList(head, data);
            }
            coderInThirtyDays.DisplayLinkedList(head);
        }
Exemple #12
0
        static void RunBitwiseAND()
        {
            var testsAmount       = Convert.ToInt32(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();

            for (var i = 0; i < testsAmount; i++)
            {
                string[] inputs         = Console.ReadLine().Split(' ');
                var      rightSetBorder = Convert.ToInt32(inputs[0]);
                var      lessThanValue  = Convert.ToInt32(inputs[1]);
                Console.WriteLine(coderInThirtyDays.FindMaxPossibleValueOfBitwiseOperation(rightSetBorder, lessThanValue));
            }
        }
Exemple #13
0
        static void RunMoreLinkedLists()
        {
            Node head              = null;
            var  nodesAmount       = Int32.Parse(Console.ReadLine());
            var  coderInThirtyDays = new CoderInThirtyDays();

            while (nodesAmount-- > 0)
            {
                var data = Int32.Parse(Console.ReadLine());
                head = coderInThirtyDays.InsertNodeToLinkedList(head, data);
            }
            head = coderInThirtyDays.RemoveDuplicatesInLinkedList(head);
            coderInThirtyDays.DisplayLinkedList(head);
        }
Exemple #14
0
        static void RunBinarySearchTrees()
        {
            TreeNode root              = null;
            var      nodesAmount       = Int32.Parse(Console.ReadLine());
            var      coderInThirtyDays = new CoderInThirtyDays();

            while (nodesAmount-- > 0)
            {
                var data = Int32.Parse(Console.ReadLine());
                root = coderInThirtyDays.InsertIntoTree(root, data);
            }
            int height = coderInThirtyDays.GetTreeHeight(root);

            Console.WriteLine(height);
        }
Exemple #15
0
        static void RunLetsReview()
        {
            var testsAmount = Convert.ToInt32(Console.ReadLine());
            var inputs      = new List <string>();

            for (var i = 0; i < testsAmount; i++)
            {
                var inputString = Console.ReadLine();
                inputs.Add(inputString);
            }
            foreach (var reviewInput in inputs)
            {
                var coderInThirtyDays = new CoderInThirtyDays();
                var resultString      = coderInThirtyDays.RegroupStringByEvenAndOddCharacters(reviewInput);
                Console.WriteLine(resultString);
            }
        }
Exemple #16
0
        static void RunBSTLevelOrderTraversal()
        {
            TreeNode root              = null;
            var      nodesAmount       = Int32.Parse(Console.ReadLine());
            var      coderInThirtyDays = new CoderInThirtyDays();

            while (nodesAmount-- > 0)
            {
                var data = Int32.Parse(Console.ReadLine());
                root = coderInThirtyDays.InsertIntoTree(root, data);
            }
            List <int> result = coderInThirtyDays.GetBreadthFirstAllNodesInTree(root);

            foreach (var item in result)
            {
                Console.Write($"{ item } ");
            }
        }
Exemple #17
0
        static void RunRegExPatternsAndIntroToDatabases()
        {
            var personsAmount     = Convert.ToInt32(Console.ReadLine());
            var coderInThirtyDays = new CoderInThirtyDays();
            var personalDataList  = new List <PersonalData>();

            for (var i = 0; i < personsAmount; i++)
            {
                string[] inputs    = Console.ReadLine().Split(' ');
                string   firstName = inputs[0];
                string   emailID   = inputs[1];
                personalDataList.Add(new PersonalData(firstName, emailID));
            }
            List <string> result = coderInThirtyDays.GetAlphabeticallyOrderedListOfFirstNamesForEveryUserWithAGmailAccount(personalDataList);

            foreach (var name in result)
            {
                Console.WriteLine(name);
            }
        }
Exemple #18
0
        static void RunGenerics()
        {
            var coderInThirtyDays = new CoderInThirtyDays();
            var arrayLength       = Convert.ToInt32(Console.ReadLine());
            var intArray          = new int[arrayLength];

            for (var i = 0; i < arrayLength; i++)
            {
                intArray[i] = Convert.ToInt32(Console.ReadLine());
            }

            arrayLength = Convert.ToInt32(Console.ReadLine());
            var stringArray = new string[arrayLength];

            for (var i = 0; i < arrayLength; i++)
            {
                stringArray[i] = Console.ReadLine();
            }

            coderInThirtyDays.PrintArray <Int32>(intArray);
            coderInThirtyDays.PrintArray <String>(stringArray);
        }
Exemple #19
0
        static void RunDictionariesAndMaps()
        {
            var entriesLength = Convert.ToInt32(Console.ReadLine());
            var input         = new string[entriesLength];

            for (var i = 0; i < entriesLength; i++)
            {
                input[i] = Console.ReadLine();
            }
            var coderInThirtyDays = new CoderInThirtyDays();
            Dictionary <string, string> phoneBook = coderInThirtyDays.GeneratePhoneBook(input);
            string name;
            var    names = new List <string>();

            while ((name = Console.ReadLine()) != null)
            {
                names.Add(name);
            }
            foreach (var nameElement in names)
            {
                string result = coderInThirtyDays.FindNumberInPhoneBook(phoneBook, nameElement);
                Console.WriteLine(result);
            }
        }