public void SubmitSolution() { var problemsRepo = new ProblemsRepo(); var goodTasks = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 38, 39, 40, 41, 42, 46 }; // var goodTasks = new[] { 13 }; var apiClient = new ApiClient(); foreach (var p in goodTasks) { try { Console.WriteLine($"!solving: {p}"); var problemSpec = problemsRepo.Get(p); var solutionSpec = UltraSolver.AutoSolve(problemSpec); var postSolution = apiClient.PostSolution(p, solutionSpec); Console.WriteLine(postSolution); problemsRepo.PutSolution(p, solutionSpec); problemsRepo.PutResponse(p, postSolution); } catch (Exception e) { problemsRepo.PutSolution(p, e.ToString()); } Thread.Sleep(1000); } }
public void SubmitSolutions(int problemId) { ImperfectSolver solver = new ImperfectSolver(); Console.WriteLine($"problemId = {problemId}"); var repo = new ProblemsRepo(); var spec = repo.Get(problemId); var solution = solver.SolveMovingInitialSquare(spec); var res = apiClient.PostSolution(problemId, solution); Console.WriteLine(res); repo.PutSolution(problemId, solution); repo.PutResponse(problemId, res); Thread.Sleep(1000); }
public static void Run() { var pr = new ProblemsRepo(); var problemSpecs = pr.GetAllProblemSpecContentAndId().ToList(); var specSolutionResponse = problemSpecs.ToDictionary(p => p.Item2, p => Tuple.Create( p.Item1, //spec pr.FindSolution(p.Item2), //sln pr.FindResponse(p.Item2), //resp p.Item2 )); var sameSpecs = new Dictionary <string, List <Tuple <string, string, string, int> > >(); foreach (var pair in specSolutionResponse) { if (!sameSpecs.ContainsKey(pair.Value.Item1)) { sameSpecs[pair.Value.Item1] = new List <Tuple <string, string, string, int> >(); } sameSpecs[pair.Value.Item1].Add(pair.Value); } var toSolve = new Dictionary <int, List <int> >(); foreach (var taskInfos in sameSpecs) { var sln = ""; var id = 0; foreach (var taskInfo in taskInfos.Value) { if (sln != "" || taskInfo.Item3 != null && !taskInfo.Item3.Contains("\"resemblance\":1.0")) { continue; } sln = taskInfo.Item3; id = taskInfo.Item4; } if (sln == "") { continue; } var list = taskInfos.Value .Where(taskInfo => taskInfo.Item3 == null || !taskInfo.Item3.Contains("\"resemblance\":1.0")) .Select(taskInfo => taskInfo.Item4) .ToList(); if (list.Count != 0) { toSolve[id] = list; } } var client = new ApiClient(); foreach (var kvp in toSolve) { if (kvp.Value.Count == 0) { continue; } var sln = pr.FindSolution(kvp.Key); if (sln == null) { continue; } foreach (var id in kvp.Value) { try { var response = client.PostSolution(id, sln); pr.PutResponse(id, response); pr.PutSolution(id, sln); Console.WriteLine(JObject.Parse(response)["resemblance"].Value <double>()); } catch (Exception e) { Console.WriteLine(); Console.WriteLine(e); Console.WriteLine(0); } }