// 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); }
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); }
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); }
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); }
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); }
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 })); }
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); }
public void test1(string S, string expected) { var cl = new Problem1(); var result = cl.solution(S); Assert.AreEqual(expected, result); }
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)); }
public void Input1() { var str = "aabbbccccdddddeeeeee"; var toDelete = 4; var r = Problem1.DeleteCharacters(str, toDelete); Assert.Equal(4, r); }
public void Input6() { var str = ""; var toDelete = 0; var r = Problem1.DeleteCharacters(str, toDelete); Assert.Equal(0, r); }
public void Input4() { var str = "abcdefgg"; var toDelete = 2; var r = Problem1.DeleteCharacters(str, toDelete); Assert.Equal(5, r); }
public void Input3() { var str = "abccddeeff"; var toDelete = 10; var r = Problem1.DeleteCharacters(str, toDelete); Assert.Equal(0, r); }
public void Input2() { var str = "abcdef"; var toDelete = 0; var r = Problem1.DeleteCharacters(str, toDelete); Assert.Equal(6, r); }
public void IndexInSequence_1stTerm() { var problem = new Problem1(); var result = problem.IndexInSequence(4, 4); Assert.AreEqual(1, result); }
public Problem1Benchmarks() { var numbers = Enumerable .Range(0, 1000000) .ToArray(); _problem = new Problem1(numbers); }
public void NaturalNumbers_BelowGivenNumber(int below, IEnumerable <int> expected) { //Act var result = Problem1.GetNaturalNumbersBelow(below); //Assert Assert.Equal(expected, result); }
public void SumNaturalNumbersMultipleOfGivenBelowGiven_ResultsExpectedSum(int below, int expected, params int[] multiple) { //Act var actual = Problem1.SumNaturalNumbersMultipleOfGivenBelowGiven(below, multiple); //Assert Assert.Equal(expected, actual); }
public void SumOfMultiples_InvalidMultiplier2() { var problem = new Problem1(); var result = problem.SumOfMultiples(-10, 10); Assert.Fail(); }
public void LargestNumberInSeries_InvalidLimit2() { var problem = new Problem1(); var result = problem.IndexInSequence(1, -2); Assert.Fail(); }
public void SumOfMultiples_InvalidLimit2() { var problem = new Problem1(); var result = problem.SumOfMultiples(1, 0); Assert.Fail(); }
public void TestMethod1() { Problem1 p = new Problem1(); bool res = p.NumbersHaveSum(new int[] { 10, 15, 3, 7 }, 17); Assert.IsTrue(res); }
public void SumOfMultiples_Test3() { var problem = new Problem1(); var result = problem.SumOfMultiples(3, 10); Assert.AreEqual(18, result); }
public void SolutionShouldMatch(SingleLimitProblemArgs arguments, string expectedResult) { var problem = new Problem1(); var result = problem.Solve(arguments); Assert.AreEqual(expectedResult, result); }
public void LargestNumberInSeries_InvalidLimit1() { var problem = new Problem1(); var result = problem.LargestNumberInSeries(10, 3); Assert.Fail(); }
public void TestStatedAnswer() { int expected = 23; var prob = new Problem1(10); int actual = (int)prob.Resolve(); Assert.AreEqual(expected, actual); }
public void CalculatesEquationSum(int n, long expectedSum) { var sut = new Problem1(); var result = sut.CalculateEquation(n); Assert.AreEqual(expectedSum, result); }
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); }
public void SetUp() { _problem1 = new Problem1(); }