public void IsHappyNumber_with_16_should_be_false()
        {
            // Arrange

            // Act
            var actual = HappyNumber.IsHappyNumber(16);

            // Assert
            Assert.IsFalse(actual);
        }
        public void IsHappyNumber_with_19_should_be_true()
        {
            // Arrange

            // Act
            var actual = HappyNumber.IsHappyNumber(19);

            // Assert
            Assert.IsTrue(actual);
        }
예제 #3
0
        private static void InterviewTestCode()
        {
            var inputs = new List <int> {
                19, 2, 12
            };

            foreach (var input in inputs)
            {
                Console.WriteLine($"{input} -> {HappyNumber.IsHappyNumber(input)}");
                Console.WriteLine($"Recursion -> {input} -> {HappyNumber.IsHappyNumberRecursion(input)}");
            }
        }
        static void Main(string[] args)
        {
            System.Console.WriteLine("Bitte Zahl eingeben:");
            var zahlString = System.Console.ReadLine();
            var zahl       = int.Parse(zahlString);

            HappyNumber.Ausgabe = new Ausgabe();
            var happyNumber = HappyNumber.IsHappyNumber(zahl);

            if (happyNumber)
            {
                System.Console.WriteLine("Die Zahl ist eine super fröhliche Nummer :)");
            }
            else
            {
                System.Console.WriteLine("Die Zahl ist ein Marvin :(");
            }

            System.Console.ReadKey();
        }
예제 #5
0
        static void Main(string[] args)
        {
            LinkedList cyclicList = new LinkedList();

            cyclicList.Insert(6);
            cyclicList.Insert(5);
            cyclicList.Insert(4);
            cyclicList.Insert(3);
            cyclicList.Insert(2);
            cyclicList.Insert(1);
            cyclicList.MakeCyclic(3);

            var isCyclic = CyclicLinkedList.IsCyclic(cyclicList);

            Console.WriteLine($"Is the List Cyclic: {isCyclic}");

            Console.WriteLine();

            var cyclicLength = CyclicLinkedList.FindCyclicLLLength(cyclicList.Head);

            Console.WriteLine($"Cycle Length: {cyclicLength}");

            var educativeCycleLength = CyclicLinkedList.FindCycleLength(cyclicList.Head);

            Console.WriteLine($"Educative Cycle Length: {educativeCycleLength}");

            Console.WriteLine();

            var start = CyclicLinkedList.FindCycleStart(cyclicList.Head);

            Console.WriteLine($"Start of the list: {start.Value}");

            Console.WriteLine();

            var educativeStart = LinkedListStart.FindCycleStart(cyclicList.Head);

            Console.WriteLine($"Starting Node (Educative): {educativeStart.Value}");

            Console.WriteLine();

            var happyNumber = HappyNumber.IsHappyNumber(23);

            Console.WriteLine($"Is number happy? {happyNumber}");

            Console.WriteLine();

            var fastSlowHappyNumber = HappyNumber.IsHappyNumberFastSlow(1234);

            Console.WriteLine($"Is number happy (Fast/Slow)? {fastSlowHappyNumber}");

            Console.WriteLine();

            LinkedList ll = new LinkedList();

            ll.Insert(6);
            ll.Insert(5);
            ll.Insert(4);
            ll.Insert(3);
            ll.Insert(2);
            ll.Insert(1);

            var middle = MiddleNode.FindMiddleNode(ll.Head);

            Console.WriteLine($"The middle node is: {middle.Value}");

            Console.WriteLine();

            LinkedList palList = new LinkedList();

            palList.Insert(2);
            palList.Insert(4);
            palList.Insert(6);
            palList.Insert(4);
            palList.Insert(2);

            bool isPal = PalindromeLinkedList.IsLinkedListAPalindrome(palList.Head);

            Console.WriteLine($"Is the List a Palindrome? {isPal}");

            Console.WriteLine();
        }