Last active
November 2, 2020 22:41
-
-
Save marzvrover/8d0503855c9d6c501a01e8b4f604430a to your computer and use it in GitHub Desktop.
Randomly outputs a value from a new line separated list retrieved from stdin
This file contains hidden or 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.Generic; | |
namespace Marzvrover | |
{ | |
class Picker | |
{ | |
static void Main(string[] args) | |
{ | |
string input; | |
List<string> list = new List<string>(); | |
while (!string.IsNullOrEmpty(input = Console.ReadLine())) | |
{ | |
list.Add(input); | |
} | |
Random index = new Random(); | |
Console.WriteLine(list[index.Next(0, list.Count)]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment