Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BagApplication
- {
- class Program
- {
- public static Dictionary<string, int> Bag = new Dictionary<string, int> {
- {"A",9},{"B",2},{"C",2},{"D",4},{"E",12},{"F",2},{"G",3},{"H",2},{"I",9},
- {"J",1},{"K",1},{"L",4},{"M",2},{"N",6},{"O",8},{"P",2},{"Q",1},{"R",6},
- {"S",4},{"T",6},{"U",4},{"V",2},{"W",2},{"X",1},{"Y",2},{"Z",1},{"_",2}
- };
- static void Main(string[] args)
- {
- Console.WriteLine("Bag Program thing");
- RemoveFromBag("AXHDRUIOR_XHJZUQEE");
- //Used so the CMD window stays to see output
- Console.ReadLine();
- }
- static void PrintBag(){
- for (int B = 12; B+1 > 0; B-=1){
- List<string> Letters = new List<string>();
- var Matches = Bag.Where(kvp => kvp.Value == B).ToList();
- if (Matches.Count > 0)
- {
- string AllLetters = "";
- AllLetters = string.Join(",", Matches.Select(item => item.Key.ToString()));
- Console.WriteLine(B + ":" + AllLetters);
- }
- }
- }
- static void RemoveFromBag(string Input){
- for (int I = 0; I < Input.Length; I++){
- int Count = Bag[Input[I].ToString()];
- Bag[Input[I].ToString()] = Count - 1;
- if ((Count - 1) < 0){
- Console.WriteLine("Invaild Output. More " + Input[I].ToString() + "'s taken from the bag then possible.");
- return;
- }
- }
- PrintBag();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment