// GET api/problem/1
        public string Get(int id)
        {
            string result  = "";
            Solver problem = new Problem1();

            if (id == 1)
            {
                problem = new Problem1();
            }
            if (id == 2)
            {
                problem = new Problem2();
            }
            if (id == 3)
            {
                problem = new Problem3();
            }
            if (id == 4)
            {
                problem = new Problem4();
            }
            if (id == 5)
            {
                problem = new Problem5();
            }

            problem.Solve();
            return(problem.Solution);



            return(result);
        }
Example #2
0
        public void given_long_phrase_and_high_value_when_processed_returns_correctly_split_phrase()
        {
            // Arrange.
            const string expected = @"Lorem ipsum dolor sit amet, mel magna dolore rationibus no, ea
pericula gubergren has. In vidisse percipit vix, qui amet adipiscing
no, eum ad malis dicit. Ut eirmod commune eos. Vix case officiis no,
decore nominavi te quo, stet appareat philosophia his ei. Te sea viris
nemore neglegentur, ad eam dicit detracto partiendo. Minim impedit
nominavi ut has, feugiat recteque id usu, at pro debitis forensibus
delicatissimi. Assum accommodare qui ad. Officiis neglegentur ut ius,
aliquip invenire reformidans ex sit. Te legere disputationi his, nam
ad utamur omittam apeirian. Cu vero paulo oportere qui, in suscipit
lucilius consetetur ius. Ludus vocibus ad sed, ex vel eirmod feugiat
nominavi, nostro inciderint mediocritatem vix et. At has sale denique,
quo platonem democritum ullamcorper id. Modus similique sea at.
";

            const string phrase = @"
Lorem ipsum dolor sit amet, mel magna dolore rationibus no, ea pericula gubergren has. In vidisse percipit vix, qui amet adipiscing no, eum ad malis dicit. Ut eirmod commune eos. Vix case officiis no, decore nominavi te quo, stet appareat philosophia his ei. Te sea viris nemore neglegentur, ad eam dicit detracto partiendo. Minim impedit nominavi ut has, feugiat recteque id usu, at pro debitis forensibus delicatissimi. Assum accommodare qui ad. 
Officiis neglegentur ut ius, aliquip invenire reformidans ex sit. Te legere disputationi his, nam ad utamur omittam apeirian. Cu vero paulo oportere qui, in suscipit lucilius consetetur ius. Ludus vocibus ad sed, ex vel eirmod feugiat nominavi, nostro inciderint mediocritatem vix et. At has sale denique, quo platonem democritum ullamcorper id. Modus similique sea at.";

            // Act.
            var result = Problem1.Process(phrase, 70);

            // Assert.
            result.Should().Be(expected);
        }
Example #3
0
        public void Process_large_file()
        {
            var input   = File.ReadAllText("../../B-large-practice.in");
            var results = Problem1.Solver(input);

            File.WriteAllLines("../../B-large-practice.out", results);
        }
Example #4
0
        public void Process_vlarge_file()
        {
            var lines   = File.ReadLines("../../E");
            var results = Problem1.Solver(lines, false);

            File.WriteAllLines("../../E.out", results);
        }
        public void TestFindResultingFrequency()
        {
            var testInput1 = new List <string>
            {
                "+1",
                "+1",
                "+1"
            };

            var testInput2 = new List <string>
            {
                "+1",
                "+1",
                "-2"
            };

            var testInput3 = new List <string>
            {
                "-1",
                "-2",
                "-3"
            };

            Assert.AreEqual(3, Problem1.FindResultingFrequency(testInput1));
            Assert.AreEqual(0, Problem1.FindResultingFrequency(testInput2));
            Assert.AreEqual(-6, Problem1.FindResultingFrequency(testInput3));
        }
        public void GetMultiplesOfThreeAndFive_ReturnsCorrectMultiples(int naturalNumber, int expected)
        {
            var classUnderTests = new Problem1();
            var actual = classUnderTests.GetSumOfMultiples(naturalNumber);

            Assert.Equal(expected, actual);
        }
Example #7
0
        public static IEnumerable <Problem> GetProblems()
        {
            List <Problem> list = new List <Problem>();
            Problem        tmp;

            // Problem 1
            tmp = new Problem1();
            list.Add(tmp);
            // Problem 2
            tmp = new OffsetProblem(3, 0.86);
            list.Add(tmp);
            // Problem 3
            tmp = new DefaultProblem("medium");
            list.Add(tmp);
            // Problem 4
            tmp = new DefaultProblem("n");
            list.Add(tmp);
            // Problem 5
            tmp = new NumberProblem(65, 0.08);
            list.Add(tmp);
            // Problem 6
            tmp = new Problem6();
            list.Add(tmp);
            return(list);
        }
Example #8
0
        public void TestMethod1()
        {
            var p1  = new Problem1();
            var sum = p1.SumArray(p1.FindMultiples(10, new int[] { 3, 5 }));

            sum = p1.SumArray(p1.FindMultiples(1000, new int[] { 3, 5 }));
        }
Example #9
0
        public static IEnumerable <Problem> GetProblems()
        {
            List <Problem> list = new List <Problem>();
            Problem        tmp;

            // Problem 1
            tmp = new Problem1();
            list.Add(tmp);
            // Problem 2
            tmp = new DefaultProblem("n");
            list.Add(tmp);
            // Problem 3
            tmp = new NumberProblem(99.4, NumberProblem.ACE * 2.5, 1.25);
            list.Add(tmp);
            // Problem 4
            tmp = new NumberProblem(964, 0.6, 1.3);
            list.Add(tmp);
            // Problem 5
            tmp = new OffsetProblem(39, 1 / 7.0, 1, 6);
            list.Add(tmp);
            // Problem 6
            tmp = new NumberProblem(2.6375, NumberProblem.ACE);
            list.Add(tmp);
            return(list);
        }
Example #10
0
        public void test1(string S, string expected)
        {
            var cl     = new Problem1();
            var result = cl.solution(S);

            Assert.AreEqual(expected, result);
        }
Example #11
0
 private static void Main()
 {
     Problem0.test();
     Problem1.test();
     Problem1c.test();
     Problem2.test();
 }
        public void TestFindValuesToSum()
        {
            var input = new [] { 1721, 979, 366, 299, 675, 1456 };

            Assert.AreEqual(514579, Problem1.FindAnswerOne(input, 2020));
            Assert.AreEqual(241861950, Problem1.FindAnswerTwo(input, 2020));
        }
Example #13
0
        public void Input1()
        {
            var str      = "aabbbccccdddddeeeeee";
            var toDelete = 4;
            var r        = Problem1.DeleteCharacters(str, toDelete);

            Assert.Equal(4, r);
        }
Example #14
0
        public void Input6()
        {
            var str      = "";
            var toDelete = 0;
            var r        = Problem1.DeleteCharacters(str, toDelete);

            Assert.Equal(0, r);
        }
Example #15
0
        public void Input4()
        {
            var str      = "abcdefgg";
            var toDelete = 2;
            var r        = Problem1.DeleteCharacters(str, toDelete);

            Assert.Equal(5, r);
        }
Example #16
0
        public void Input3()
        {
            var str      = "abccddeeff";
            var toDelete = 10;
            var r        = Problem1.DeleteCharacters(str, toDelete);

            Assert.Equal(0, r);
        }
Example #17
0
        public void Input2()
        {
            var str      = "abcdef";
            var toDelete = 0;
            var r        = Problem1.DeleteCharacters(str, toDelete);

            Assert.Equal(6, r);
        }
Example #18
0
        public void IndexInSequence_1stTerm()
        {
            var problem = new Problem1();

            var result = problem.IndexInSequence(4, 4);

            Assert.AreEqual(1, result);
        }
Example #19
0
        public Problem1Benchmarks()
        {
            var numbers = Enumerable
                          .Range(0, 1000000)
                          .ToArray();

            _problem = new Problem1(numbers);
        }
Example #20
0
        public void NaturalNumbers_BelowGivenNumber(int below, IEnumerable <int> expected)
        {
            //Act
            var result = Problem1.GetNaturalNumbersBelow(below);

            //Assert
            Assert.Equal(expected, result);
        }
Example #21
0
        public void SumNaturalNumbersMultipleOfGivenBelowGiven_ResultsExpectedSum(int below, int expected, params int[] multiple)
        {
            //Act
            var actual = Problem1.SumNaturalNumbersMultipleOfGivenBelowGiven(below, multiple);

            //Assert
            Assert.Equal(expected, actual);
        }
Example #22
0
        public void SumOfMultiples_InvalidMultiplier2()
        {
            var problem = new Problem1();

            var result = problem.SumOfMultiples(-10, 10);

            Assert.Fail();
        }
Example #23
0
        public void LargestNumberInSeries_InvalidLimit2()
        {
            var problem = new Problem1();

            var result = problem.IndexInSequence(1, -2);

            Assert.Fail();
        }
Example #24
0
        public void SumOfMultiples_InvalidLimit2()
        {
            var problem = new Problem1();

            var result = problem.SumOfMultiples(1, 0);

            Assert.Fail();
        }
Example #25
0
        public void TestMethod1()
        {
            Problem1 p = new Problem1();

            bool res = p.NumbersHaveSum(new int[] { 10, 15, 3, 7 }, 17);

            Assert.IsTrue(res);
        }
Example #26
0
        public void SumOfMultiples_Test3()
        {
            var problem = new Problem1();

            var result = problem.SumOfMultiples(3, 10);

            Assert.AreEqual(18, result);
        }
Example #27
0
        public void SolutionShouldMatch(SingleLimitProblemArgs arguments, string expectedResult)
        {
            var problem = new Problem1();

            var result = problem.Solve(arguments);

            Assert.AreEqual(expectedResult, result);
        }
Example #28
0
        public void LargestNumberInSeries_InvalidLimit1()
        {
            var problem = new Problem1();

            var result = problem.LargestNumberInSeries(10, 3);

            Assert.Fail();
        }
Example #29
0
        public void TestStatedAnswer()
        {
            int expected = 23;
            var prob     = new Problem1(10);
            int actual   = (int)prob.Resolve();

            Assert.AreEqual(expected, actual);
        }
Example #30
0
        public void CalculatesEquationSum(int n, long expectedSum)
        {
            var sut = new Problem1();

            var result = sut.CalculateEquation(n);

            Assert.AreEqual(expectedSum, result);
        }
Example #31
0
        public void Solution()
        {
            var sut = new Problem1();

            var result = sut.Calculate(1000);

            Console.WriteLine(result);
        }
 public void Solve()
 {
     var result = new Problem1().Solve();
     Assert.AreEqual(result, 233168);
 }
Example #33
0
 public void SetUp()
 {
     _problem1 = new Problem1();
 }