Advertisement
silvana1303

bombs

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