using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
private static Random random = new Random();
List<int> boxNumbers = new List<int> { 2, 3, 4, 5, 6, 7, 8, 9};
int diceRoll = dice1 + dice2;
Console.WriteLine("Welcome to shut the box!\n");
Console.WriteLine("Press Enter to roll dice.");
diceRoll = dice1 + dice2;
Console.WriteLine($"You rolled {dice1} and {dice2}");
Console.WriteLine($"you need to remove {diceRoll} to contine");
for(int i = 0; i < boxNumbers.Count; i++)
int check1 = boxNumbers[i];
if (check1 == diceRoll) playable = true;
for (int j = 0; j < boxNumbers.Count; j++)
int check2 = boxNumbers[j] + boxNumbers[i];
if (check2 == diceRoll) playable = true;
for (int k = 0; k < boxNumbers.Count; k++)
int check3 = boxNumbers[k] + boxNumbers[j] + boxNumbers[i];
if (check3 == diceRoll) playable = true;
Console.WriteLine("please select a number to close");
Console.Write("Number: ");
string? input = Console.ReadLine();
int numberImput = Convert.ToInt32(input);
if (boxNumbers.Contains(numberImput)&& numberImput <= diceRoll)
selectedNumber = numberImput;
else throw new Exception();
catch{ Console.Write("Please enter a valid number: "); }
boxNumbers.Remove(selectedNumber);
diceRoll = diceRoll - selectedNumber;
if (boxNumbers.Count == 0 )
Console.WriteLine("Congratulations you win!");
Console.WriteLine("Game Over");
public static int RollD6()
static void PrintBox(List<int> boxNumbers)
int [] boxFlaps = { 2, 3, 4, 5, 6, 7, 8, 9};
foreach ( int flap in boxFlaps)
if (boxNumbers.Contains((int)flap))
Console.Write($"| {flap} |");