Advertisement
Daniel_007

01. Bombs

Jun 28th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.50 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int[] bombEffectsInput = Console.ReadLine().Split(", ").Select(int.Parse).ToArray();
  13.             int[] bombCasingsInput = Console.ReadLine().Split(", ").Select(int.Parse).ToArray();
  14.             Queue<int> bombEffects = new Queue<int>();
  15.             Stack<int> bombCasing = new Stack<int>();
  16.             Dictionary<string, int> bombs = new Dictionary<string, int>();
  17.             int daturaBombs = 40;
  18.             bombs["Datura Bombs"] = 0;
  19.             int cherryBombs = 60;
  20.             bombs["Cherry Bombs"] = 0;
  21.             int smokeBombs = 120;
  22.             bombs["Smoke Decoy Bombs"] = 0;
  23.  
  24.             foreach (var effect in bombEffectsInput)
  25.             {
  26.                 bombEffects.Enqueue(effect);
  27.             }
  28.  
  29.             foreach (var casing in bombCasingsInput)
  30.             {
  31.                 bombCasing.Push(casing);
  32.             }
  33.  
  34.             bool pouch = false;
  35.             //------------------------------------
  36.             while (bombCasing.Count > 0 && bombEffects.Count > 0)
  37.             {
  38.                 int currentMix = bombCasing.Peek() + bombEffects.Peek();
  39.                 if (bombs["Cherry Bombs"] >= 3 && bombs["Datura Bombs"] >= 3 && bombs["Smoke Decoy Bombs"] >= 3)
  40.                 {
  41.                     pouch = true;
  42.                     break;
  43.                 }
  44.                 if (currentMix == cherryBombs)
  45.                 {
  46.                     bombs["Cherry Bombs"]++;
  47.                     bombCasing.Pop();
  48.                     bombEffects.Dequeue();
  49.                 }
  50.                 else if (currentMix == daturaBombs)
  51.                 {
  52.                     bombs["Datura Bombs"]++;
  53.                     bombCasing.Pop();
  54.                     bombEffects.Dequeue();
  55.                 }
  56.                 else if (currentMix == smokeBombs)
  57.                 {
  58.                     bombs["Smoke Decoy Bombs"]++;
  59.                     bombCasing.Pop();
  60.                     bombEffects.Dequeue();
  61.                 }
  62.                 else
  63.                 {
  64.                     int temp = bombCasing.Pop();
  65.                     temp -= 5;
  66.                     bombCasing.Push(temp);
  67.                 }
  68.             }
  69.             //--------------------------
  70.             if (pouch)
  71.             {
  72.                 Console.WriteLine("Bene! You have successfully filled the bomb pouch!");
  73.             }
  74.             else
  75.             {
  76.                 Console.WriteLine("You don't have enough materials to fill the bomb pouch.");
  77.             }
  78.             //--------------------------
  79.             if (bombEffects.Count > 0)
  80.             {
  81.                 Console.WriteLine($"Bomb Effects: {string.Join(", ",bombEffects)}");
  82.  
  83.             }
  84.             else
  85.             {
  86.                 Console.WriteLine("Bomb Effects: empty");
  87.             }
  88.             //--------------------------
  89.             if (bombCasing.Count > 0)
  90.             {
  91.                 Console.WriteLine($"Bomb Casings: {string.Join(", ", bombCasing)}");
  92.             }
  93.             else
  94.             {
  95.                 Console.WriteLine("Bomb Casings: empty");
  96.             }
  97.  
  98.             Console.WriteLine($"Cherry Bombs: {bombs["Cherry Bombs"]}");
  99.             Console.WriteLine($"Datura Bombs: {bombs["Datura Bombs"]}");
  100.             Console.WriteLine($"Smoke Decoy Bombs: {bombs["Smoke Decoy Bombs"]}");
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement