Skip to content

Instantly share code, notes, and snippets.

@97997
Created October 4, 2020 20:12
Show Gist options
  • Save 97997/f62edb152a6ab4fe3bd81e4801c86b8c to your computer and use it in GitHub Desktop.
Save 97997/f62edb152a6ab4fe3bd81e4801c86b8c to your computer and use it in GitHub Desktop.
Russian Roulette
using System;
using System.Collections;
using System.Linq;
namespace RandomSelector
{
class Program
{
static void Main(string[] args)
{
russianRoulette();
}
static void russianRoulette()
{
string itemFilename = "selection.txt";
string[] lines = System.IO.File.ReadAllLines(itemFilename);
string selected = "";
while (true)
{
Random rnd = new Random();
string[] randomizedItemList = lines.OrderBy(x => rnd.Next()).ToArray();
foreach (string line in randomizedItemList)
{
if ((line == selected) == false)
{
selected = line;
System.Console.WriteLine(selected);
System.Console.ReadKey();
Console.Clear();
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment