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); }
public void _50_per_year() => AdventDate.AllAvailable(new Date(2015, 12, 26)).Should().HaveCount(50);
public void None_before_2015_december_1() => AdventDate.AllAvailable(new Date(2015, 11, 30)).Should().BeEmpty();
public void Two_at_2015_december_1_after_5AM() => AdventDate.AllAvailable(new DateTime(2015, 12, 01, 05, 00, 00, DateTimeKind.Utc)).Should().HaveCount(2);