示例#1
0
        public void ContinuedFraction_Examples_ReturnsResult(int n, int numerator, int denominator)
        {
            var expectedFraction = new Rational(numerator, denominator);
            var actualFraction   = Problem57.ContinuedFraction(n);

            Assert.True(expectedFraction == actualFraction);
        }
示例#2
0
        public void Iteration7Test()
        {
            // Arrange
            BigRational two = new(2);

            BigInteger expectedNumerator   = 1393;
            BigInteger expectedDenominator = 985;

            // Act
            BigRational innerExpression1 = Problem57.CalculateInnerExpression(two);
            BigRational innerExpression2 = Problem57.CalculateInnerExpression(innerExpression1);
            BigRational innerExpression3 = Problem57.CalculateInnerExpression(innerExpression2);
            BigRational innerExpression4 = Problem57.CalculateInnerExpression(innerExpression3);
            BigRational innerExpression5 = Problem57.CalculateInnerExpression(innerExpression4);
            BigRational innerExpression6 = Problem57.CalculateInnerExpression(innerExpression5);
            BigRational innerExpression7 = Problem57.CalculateInnerExpression(innerExpression6);
            BigRational outerExpression  = Problem57.CalculateOuterExpression(innerExpression7);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(outerExpression.Numerator, Is.EqualTo(expectedNumerator));
                Assert.That(outerExpression.Denominator, Is.EqualTo(expectedDenominator));
            });
        }
示例#3
0
        public void InnerExpressionTest()
        {
            // Arrange
            BigRational two = new(2);

            BigInteger expectedNumerator   = 5;
            BigInteger expectedDenominator = 2;

            // Act
            BigRational innerExpression = Problem57.CalculateInnerExpression(two);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(innerExpression.Numerator, Is.EqualTo(expectedNumerator));
                Assert.That(innerExpression.Denominator, Is.EqualTo(expectedDenominator));
            });
        }
示例#4
0
 public void ReturnsSolution()
 {
     Assert.AreEqual(153, Problem57.Solution());
 }
示例#5
0
        public static void Main(string[] args)
        {
            CreateHeader();
            while (true)
            {
                Console.WriteLine("Input problem #:");
                string userInput     = "lis";
                int    problemNumber = 0;

                if (userInput == "sort")
                {
                    SortingAlgorithms SortingAlgorithms = new SortingAlgorithms();
                    SortingAlgorithms.Main();
                }
                else if (userInput == "LinkedList")
                {
                    LinkedListTest linkedList = new LinkedListTest();
                    linkedList.Main();
                }
                else if (userInput == "Fib")
                {
                    Fib fib = new Fib();
                    fib.Main();
                }
                else if (userInput == "lis")
                {
                    LISS lis = new LISS();
                    lis.Main();
                }
                else if (userInput == "search")
                {
                    SearchingAlgorithms search = new SearchingAlgorithms();
                    search.Main();
                }
                else
                {
                    bool validInput = Int32.TryParse(userInput, out problemNumber);
                    if (validInput)
                    {
                        switch (problemNumber)
                        {
                        case 1:
                            Problem1 problem1 = new Problem1();
                            problem1.Main();
                            break;

                        case 21:
                            Problem21 problem21 = new Problem21();
                            problem21.Main();
                            break;

                        case 29:
                            Problem29 problem29 = new Problem29();
                            problem29.Main();
                            break;

                        case 37:
                            Problem37 problem37 = new Problem37();
                            problem37.Main();
                            break;

                        case 44:
                            Problem44 problem44 = new Problem44();
                            problem44.Main();
                            break;

                        case 57:
                            Problem57 problem57 = new Problem57();
                            problem57.Main();
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }