| 12345678910111213141516171819 |
- namespace Day4;
- public class ScratchCard
- {
- public int Id { get; }
- public ISet<int> Winning { get; } = new HashSet<int>();
- public ISet<int> Draw { get; } = new HashSet<int>();
- public ScratchCard(int id)
- {
- Id = id;
- }
- public int GetScore()
- {
- var matches = Draw.Select(draw => Winning.Contains(draw) ? 1 : 0).Sum();
- return matches > 0 ? (int)Math.Pow(2, matches - 1) : 0;
- }
- }
|