/// <summary> /// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. /// Find the sum of all the multiples of 3 or 5 below 1000. /// </summary> /// <returns>SolutionOutput object, giving info on result of running the problem</returns> internal override SolutionOutput InnerSolve() { SolutionOutput solutionOutput = new SolutionOutput(); int answer = MultiplesOf3And5(1000); solutionOutput.Output = "The calculated answer is:" + answer; return(solutionOutput); }
/// <summary> /// Method to execute the solutions to the Project Euler problems /// </summary> /// <param name="problemNumber">The problem number to execute</param> /// <returns>SolutionOutput object, giving info on result of running the problem</returns> public static SolutionOutput RunSolution(int problemNumber) { SolutionOutput solutionOutput; try { BaseProblem problem = GetProblemInstance(problemNumber); solutionOutput = problem.Solve(); } catch (Exception exception) { solutionOutput = new SolutionOutput(); solutionOutput.ValidationResult = false; solutionOutput.Output = exception.Message; } return(solutionOutput); }
/// <summary> /// Executes the solution for the problem /// </summary> /// <returns>SolutionOutput object, giving info on result of running the problem</returns> internal SolutionOutput Solve() { SolutionOutput solutionOutput; if (!ValidationSolve()) { solutionOutput = new SolutionOutput(); solutionOutput.ValidationResult = false; solutionOutput.Output = "Validation against example failed. Not running full solve"; } else { Stopwatch timer = new Stopwatch(); timer.Start(); solutionOutput = InnerSolve(); timer.Stop(); solutionOutput.DurationMilliseconds = timer.Elapsed.TotalMilliseconds; solutionOutput.ValidationResult = true; } return(solutionOutput); }