using System.Collections.Generic;
private static Random rnd = new Random();
private static int[,] winningsTable = new int[,]{{0,1,5,10},{0,2,25,1000}};
public static void Main()
int simulationCount = 5000000;
for(int i = 0; i < simulationCount; i++)
int profit = SimulateGame();
double avgValue = totalValue * 1.0 / simulationCount;
Console.WriteLine($"EV:{avgValue}");
private static int SimulateGame()
List<int> whiteBalls = Enumerable.Range(1, 20).ToList();
List<int> lotteryWhiteBallChoices = new List<int>();
for(int i = 0; i < 3; i++)
int index = rnd.Next(0, whiteBalls.Count);
int whiteBallNumber = whiteBalls[index];
lotteryWhiteBallChoices.Add(whiteBallNumber);
whiteBalls = Enumerable.Range(1, 20).ToList();
List<int> gamblerWhiteBallChoices = new List<int>();
for(int i = 0; i < 3; i++)
int index = rnd.Next(0, whiteBalls.Count);
int whiteBallNumber = whiteBalls[index];
gamblerWhiteBallChoices.Add(whiteBallNumber);
int lotteryPowerball = rnd.Next(1, 21);
int gamblerPowerball = rnd.Next(1, 21);
bool isPowerballMatch = lotteryPowerball == gamblerPowerball;
int numberOfWhiteBallMatches = gamblerWhiteBallChoices.Intersect(lotteryWhiteBallChoices).Count();
int winnings = winningsTable[ isPowerballMatch ? 1 : 0, numberOfWhiteBallMatches];