コード例 #1
0
ファイル: Ranking.cs プロジェクト: Corniel/advent-of-code
    public static List <OverallRanking> Overall(Participants participants)
    {
        var list = new List <OverallRanking>(participants
                                             .Where(p => p.Value.Solutions.Any())
                                             .Select(p => new OverallRanking(p.Value)));

        foreach (var date in AdventDate.AllAvailable())
        {
            var score = list.Count(p => p.Solutions.Keys.Any(d => d.Year == date.Year));
            foreach (var participant in list
                     .Where(p => p.Solutions.ContainsKey(date))
                     .OrderBy(p => p.Solutions[date]))
            {
                participant.Score += score--;
            }
        }
        list.Sort();
        var pos = 1;

        foreach (var participant in list)
        {
            participant.Position = pos++;
        }
        return(list);
    }
コード例 #2
0
 public void _50_per_year()
 => AdventDate.AllAvailable(new Date(2015, 12, 26)).Should().HaveCount(50);
コード例 #3
0
 public void None_before_2015_december_1()
 => AdventDate.AllAvailable(new Date(2015, 11, 30)).Should().BeEmpty();
コード例 #4
0
 public void Two_at_2015_december_1_after_5AM()
 => AdventDate.AllAvailable(new DateTime(2015, 12, 01, 05, 00, 00, DateTimeKind.Utc)).Should().HaveCount(2);