Skip to content

Instantly share code, notes, and snippets.

@BlythMeister
Created June 11, 2021 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlythMeister/bf1a5e4b12d89fae3b1fe7e656955a61 to your computer and use it in GitHub Desktop.
Save BlythMeister/bf1a5e4b12d89fae3b1fe7e656955a61 to your computer and use it in GitHub Desktop.
Sweepstake
void Main()
{
var teams = File.ReadAllLines(@"C:\users\chris.blyth\Desktop\Teams.txt").ToList();
var people = File.ReadAllLines(@"C:\users\chris.blyth\Desktop\People.txt").ToList();
if (teams.Count > people.Count)
{
var missingPeople = teams.Count - people.Count;
for (int i = 0; i < missingPeople; i++)
{
people.Add($"Extra {i + 1}");
}
}
var random = new Random();
var max = teams.Count;
for (int i = 0; i < max; i++)
{
var nextRandomTeam = random.Next(0, teams.Count);
var team = teams[nextRandomTeam];
var nextRandomPerson = random.Next(0, people.Count);
var person = people[nextRandomPerson];
Console.WriteLine($"{person} - {team}");
teams.RemoveAt(nextRandomTeam);
people.RemoveAt(nextRandomPerson);
Thread.Sleep(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment