Guest User

Untitled

a guest
Jul 6th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace BagApplication
  8. {
  9. class Program
  10. {
  11. public static Dictionary<string, int> Bag = new Dictionary<string, int> {
  12. {"A",9},{"B",2},{"C",2},{"D",4},{"E",12},{"F",2},{"G",3},{"H",2},{"I",9},
  13. {"J",1},{"K",1},{"L",4},{"M",2},{"N",6},{"O",8},{"P",2},{"Q",1},{"R",6},
  14. {"S",4},{"T",6},{"U",4},{"V",2},{"W",2},{"X",1},{"Y",2},{"Z",1},{"_",2}
  15. };
  16.  
  17. static void Main(string[] args)
  18. {
  19. Console.WriteLine("Bag Program thing");
  20. RemoveFromBag("AXHDRUIOR_XHJZUQEE");
  21.  
  22. //Used so the CMD window stays to see output
  23. Console.ReadLine();
  24. }
  25.  
  26. static void PrintBag(){
  27. for (int B = 12; B+1 > 0; B-=1){
  28. List<string> Letters = new List<string>();
  29. var Matches = Bag.Where(kvp => kvp.Value == B).ToList();
  30. if (Matches.Count > 0)
  31. {
  32. string AllLetters = "";
  33. AllLetters = string.Join(",", Matches.Select(item => item.Key.ToString()));
  34. Console.WriteLine(B + ":" + AllLetters);
  35. }
  36. }
  37. }
  38.  
  39. static void RemoveFromBag(string Input){
  40. for (int I = 0; I < Input.Length; I++){
  41. int Count = Bag[Input[I].ToString()];
  42. Bag[Input[I].ToString()] = Count - 1;
  43. if ((Count - 1) < 0){
  44. Console.WriteLine("Invaild Output. More " + Input[I].ToString() + "'s taken from the bag then possible.");
  45. return;
  46. }
  47. }
  48. PrintBag();
  49. }
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment