using System.Collections.Generic;
public static int FindMaxPrice(Dictionary<int, int> dict)
int maxprice = dict.Values.Max();
for (int j = 0; j < 20; j++)
if (dict.ContainsKey(j) == true)
public static void Main()
Console.WriteLine("Please guess a number:");
int input = int.Parse(Console.ReadLine());
Dictionary<int, int> dict = new Dictionary<int, int>();
Random rnd = new Random();
for (int i = 0; i < 10; i++)
result = rnd.Next(1, 21);
while (dict.ContainsKey(result) == true)
result = rnd.Next(1, 21);
price = rnd.Next(1, 10001);
Console.WriteLine("{0},{1}", result, price);
if (dict.ContainsKey(input) == false)
Console.WriteLine("BANG! You die!");
Console.WriteLine("You are unlucky! If you guessed {0}, you would have won the most money!", FindMaxPrice(dict));
Console.WriteLine("You earned {0} dollars!", dict[input]);
Console.WriteLine("You are lucky! You could have lost if you guessed the following numbers: ");
for (int i = 1; i < 20; i++)
if (dict.ContainsKey(i) == false)
Console.WriteLine("{0}", i);