Esempio n. 1
0
        public static void SolveAllNotSolvedPerfectly()
        {
            var snapshotJson          = problemsRepo.GetSnapshot(new ApiClient());
            var problemToRank         = snapshotJson.Problems.ToDictionary(p => p.Id, p => p.ExpectedScore());
            var allNotSolvedPerfectly = problemsRepo.GetAllNotSolvedPerfectly().OrderByDescending(x => problemToRank[x.id]);

            SolveAll(allNotSolvedPerfectly.ToList());
        }
Esempio n. 2
0
        public void SolveRibbons()
        {
            var repo         = new ProblemsRepo();
            var snapshotJson = repo.GetSnapshot(new ApiClient());
            var ribbons      = repo.GetAllNotSolvedPerfectly().Where(IsRibbon);
            var sum          = 0d;

            foreach (var ribbon in ribbons)
            {
                var desc = snapshotJson.Problems.First(p => p.Id == ribbon.id);
                sum += desc.ExpectedScore();
                Console.WriteLine(ribbon.id + " Owner = " + desc.Owner + " Exp = " + desc.ExpectedScore());
            }
            Console.WriteLine(sum);
        }
Esempio n. 3
0
        public VisualizerForm()
        {
            try
            {
                var sortByExpectedScore = new ToolStripButton("SortByScore", null, SortByExpectedScoreClick);
                sortByExpectedScore.CheckOnClick = true;

                var sortById = new ToolStripButton("SortById", null, SortByIdClick);
                sortById.CheckOnClick = true;
                var sortByOwner = new ToolStripButton("SortByOwner", null, SortByOwnerClick);
                sortByOwner.CheckOnClick = true;

                var solve = new ToolStripButton("Solve", null, SolveClick);
                var menu  = new ToolStrip(sortByExpectedScore, sortById, sortByOwner, solve);
                list       = new ListBox();
                list.Width = 300;
                list.Dock  = DockStyle.Left;
                list.BringToFront();

                output      = new ListBox();
                output.Dock = DockStyle.Bottom;

                snapshotJson = repo.GetSnapshot(null);
                problemsJson = snapshotJson.Problems.ToDictionary(p => p.Id, p => p);

                list.Items.AddRange(GetItems(x => x));
                list.SelectedValueChanged += ListOnSelectedValueChanged;
                list.DoubleClick          += ListOnDoubleClick;

                problemPanel = new Panel()
                {
                    Dock = DockStyle.Fill,
                };

                problemPanel.Paint += (sender, args) => PaintProblem(args.Graphics, problemPanel.ClientSize);

                Size = new Size(800, 600);
                Controls.Add(problemPanel);
                Controls.Add(output);
                Controls.Add(list);
                Controls.Add(menu);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Esempio n. 4
0
        public void GetTriangles()
        {
            /*
             * 5987
             * 5988
             * 5990
             * 6100
             *
             * 16/9709 по X и по Y
             * 1077/9709 Ч ширина и высота треугольника
             * точка 1,1 Ч это вершина с пр¤мым углом
             *
             */

            var repo         = new ProblemsRepo();
            var snapshotJson = repo.GetSnapshot(new ApiClient());
            var ps           = snapshotJson.Problems.Where(p => p.Owner == "149");

            foreach (var problem in ps)
            {
                var pr     = repo.Get(problem.Id);
                var points = pr.Points.Distinct().ToList();
                if (points.Count == 7)
                {
                    var w     = points.Max(p => p.X);
                    var h     = points.Max(p => p.Y);
                    var minW1 = points.Select(p => p.X).Where(ww => ww > 0).Min();
                    var minW2 = points.Select(p => w - p.X).Where(ww => ww > 0).Min();
                    var minH1 = points.Select(p => p.Y).Where(hh => hh > 0).Min();
                    var minH2 = points.Select(p => h - p.Y).Where(hh => hh > 0).Min();
                    var minW  = minW1 > minW2 ? minW2 : minW1;
                    var minH  = minH1 > minH2 ? minH2 : minH1;

                    Console.WriteLine($"{problem.Id}, \"{w}\", \"{h}\", \"{minW}\", \"{minH}\", {minW1 < minW2}");
                }
            }
        }
Esempio n. 5
0
        public void CalculateOurScore()
        {
            var repo      = new ProblemsRepo();
            var sn        = repo.GetSnapshot(null);
            var ourScore1 = 0.0;
            var ourScore2 = 0.0;
            var ourScore3 = 0.0;

            foreach (var pr in sn.Problems)
            {
                var solutions = pr.Ranking.Count(r => r.resemblance == 1.0);
                var part      = pr.SolutionSize / (solutions + 1.0);
                var myR       = repo.GetProblemResemblance(pr.Id);
                if (myR == 1.0)
                {
                    ourScore1 += part;
                }
                else
                {
                    var rSum = pr.Ranking.Where(r => r.resemblance != 1.0).Sum(r => r.resemblance);
                    ourScore2 += part * myR / rSum;
                }
                if (pr.Owner == "89")
                {
                    ourScore3 += (5000 - pr.SolutionSize) / Math.Max(6, solutions + 1.0);
                }
            }
            Console.WriteLine(ourScore1);
            Console.WriteLine(ourScore2);
            Console.WriteLine(ourScore3);
            Console.WriteLine(ourScore1 + ourScore2 + ourScore3);
            var prCount       = repo.GetAll().Count();
            var noSolvedCount = repo.GetAllNotSolvedPerfectly().Count();

            Console.WriteLine(prCount - noSolvedCount);
            Console.WriteLine(prCount);
        }