Created
October 4, 2020 20:12
-
-
Save 97997/f62edb152a6ab4fe3bd81e4801c86b8c to your computer and use it in GitHub Desktop.
Russian Roulette
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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