// 一人増えるごとにどれか一つのリーグを一人だけ増やす = true の場合、初期値がおかしいとその後の値も軒並みおかしくなる // membersRangeStart、winnersCount の値を調整したり、 manualPredicate を厳しくするなりしよう public static void WriteResults2(int leaguesCount, int winnersCount, int firstMembersCount, int lastMembersCount, Func <LeaguesInfo, HasPreviousValue, bool> manualPredicate, bool 一人増えるごとにどれか一つのリーグを一人だけ増やす = true) { LeaguesInfo prev = null; HasPreviousValue hasPreviousValue = HasPreviousValue.False; foreach (var membersCount in Enumerable.Range(firstMembersCount, lastMembersCount - firstMembersCount + 1)) { { Write("|"); Write(membersCount.ToString()); //Write("|"); //Write(winnersCount.ToString()); //Write("|"); //Write(leaguesCount.ToString()); var writing = CreateAllLeagueInfoWithGosaCombinations(leaguesCount, membersCount, winnersCount) .Where(leaguesInfo => manualPredicate(leaguesInfo, hasPreviousValue)) .Where(leaguesInfo => { if (!一人増えるごとにどれか一つのリーグを一人だけ増やす) { return(true); } if (prev == null) { return(true); } var result = prev.Leagues .Zip(leaguesInfo.Leagues, (l1, l2) => Math.Abs(l1.MembersCount - l2.MembersCount)) .Sum() == 1; return(result); }) .OrderBy(a => Math.Abs(a.Gosa)) .FirstOrDefault(); if (writing != null) { prev = writing; hasPreviousValue = HasPreviousValue.True; Write(writing); } else { prev = null; hasPreviousValue = HasPreviousValue.False; WriteMissing(); } } } }
private static void Write(LeaguesInfo leaguesInfo) { foreach (var league in leaguesInfo.Leagues) { Write("|"); Write(league.WinnersCount.ToString()); Write("/"); Write(league.MembersCount.ToString()); Write(" ("); Write((league.WinRate * 100).ToString("0.00") + "%)"); } Write("|"); foreach (var league in leaguesInfo.Leagues.Take(leaguesInfo.Leagues.Count - 1)) { Write((league.WinRate / leaguesInfo.Leagues.Last().WinRate).ToString("0.00")); Write(":"); } Write("1"); Write("|"); Write(leaguesInfo.Gosa.ToString("0.0000")); WriteLine("|"); }