protected override void ProcessRecord() { var problems = ProblemService.GetProblems(typeof(Problems.DiscoveryProblem).Assembly); IProblem problem = null; var pr = new ProblemResult { Number = Number, }; if (problems.TryGetValue(Number, out problem)) { try { var sw = Stopwatch.StartNew(); var answer = problem.Execute(); sw.Stop(); pr.Answer = answer; pr.Duration = sw.ElapsedMilliseconds; } catch (ProblemIncompleteException) { pr.Answer = $"Problem {problem.Number} is incomplete"; } } else { pr.Answer = $"Problem not found"; } WriteObject(pr); //base.ProcessRecord(); }
static void Main(string[] args) { var solvableProblems = ProblemService.GetProblems(typeof(Problems.DiscoveryProblem).Assembly); var problemToRun = 97; RunProblems(solvableProblems, problemToRun); }