Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- namespace Bombs_CAdvancedExam_28June2020
- {
- class Program
- {
- static void Main(string[] args)
- {
- var inputBombEffects = Console.ReadLine();
- Queue<int> bombEffects = new Queue<int>(inputBombEffects.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse));
- bool flagNegative = false;
- foreach (var item in bombEffects)
- {
- if (item >= 0 && item <= 120)
- {
- flagNegative = false;
- }
- else
- {
- flagNegative = true;
- }
- }
- if (!flagNegative)
- {
- var inputBombCasing = Console.ReadLine();
- Stack<int> bombCasing = new Stack<int>(inputBombCasing.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse));
- bool flagNegativeCasing = false;
- foreach (var item in bombCasing)
- {
- if (item >= 0 && item <= 120)
- {
- flagNegativeCasing = false;
- }
- else
- {
- flagNegativeCasing = true;
- }
- }
- Dictionary<string, int> bombs = new Dictionary<string, int>();
- // bombs.Add("Datura Bombs", 0);
- int sum = 0;
- bool flag = false;
- if (!flagNegativeCasing)
- {
- while (bombCasing.Any() && bombEffects.Any())
- {
- var currentCasing = bombCasing.Peek();
- var currentEffect = bombEffects.Peek();
- sum = currentEffect + currentCasing;
- if (sum == 40 || sum == 60 || sum == 120)
- {
- if (sum == 40)
- {
- if (!bombs.ContainsKey("Datura Bombs"))
- {
- bombs.Add("Datura Bombs", 0);
- }
- bombs["Datura Bombs"]++;
- }
- else if (sum == 60)
- {
- if (!bombs.ContainsKey("Cherry Bombs"))
- {
- bombs.Add("Cherry Bombs", 0);
- }
- bombs["Cherry Bombs"]++;
- }
- else if (sum == 120)
- {
- if (!bombs.ContainsKey("Smoke Decoy Bombs"))
- {
- bombs.Add("Smoke Decoy Bombs", 0);
- }
- bombs["Smoke Decoy Bombs"]++;
- }
- bombCasing.Pop();
- bombEffects.Dequeue();
- }
- else
- {
- bombCasing.Push(bombCasing.Pop() - 5);
- }
- if (bombs.ContainsKey("Datura Bombs") && bombs.ContainsKey("Cherry Bombs") && bombs.ContainsKey("Smoke Decoy Bombs"))
- {
- if (bombs["Datura Bombs"] >= 3 && bombs["Cherry Bombs"] >= 3 && bombs["Smoke Decoy Bombs"] >= 3)
- {
- Console.WriteLine("Bene! You have successfully filled the bomb pouch!");
- flag = true;
- break;
- }
- }
- }
- if (!flag)
- {
- Console.WriteLine("You don't have enough materials to fill the bomb pouch.");
- }
- if (bombEffects.Count == 0)
- {
- Console.WriteLine("Bomb Effects: empty");
- }
- else
- {
- Console.WriteLine($"Bomb Effects: {string.Join(", ", bombEffects)}");
- }
- if (bombCasing.Count == 0)
- {
- Console.WriteLine("Bomb Casings: empty");
- }
- else
- {
- Console.WriteLine($"Bomb Casings: {string.Join(", ", bombCasing)}");
- }
- foreach (var bomb in bombs.OrderBy(k => k.Key))
- {
- Console.WriteLine($"{bomb.Key}: {bomb.Value}");
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment