public bool IsPossibleWithout(HolesSummarySlimRecord record) { var ranks = RecordString.Substring(0, 5); var holes = record.RecordString.Substring(0, 2); var totalRanks = (ranks + holes); var totalRankCount = new Dictionary <char, int>(); foreach (var rank in totalRanks) { if (!totalRankCount.ContainsKey(rank)) { totalRankCount.Add(rank, 0); } totalRankCount[rank]++; } return(totalRankCount.Values.Max() <= 4); }
public bool IsPossibleWith(HolesSummarySlimRecord record) { var ranks = RecordString.Substring(0, 5); var sameColor = RecordString.Last(); var hole1 = record.RecordString[0]; var hole2 = record.RecordString[1]; var holesSameColor = record.RecordString[2]; bool colorPossible = holesSameColor == 'S' || sameColor == 'N'; if (!colorPossible) { return(false); } if (hole1 != hole2) { return(ranks.Contains(hole1) && ranks.Contains(hole2)); } else { return(ranks.Count(r => r == hole1) >= 2); } }