Advertisement
dragonbs

TempleOfDoom

Jun 17th, 2023
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace TempleExplorer
  6. {
  7.     internal class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Queue<int> toolQueue = new Queue<int>(Console.ReadLine().Split().Select(int.Parse));
  12.             Stack<int> substanceStack = new Stack<int>(Console.ReadLine().Split().Select(int.Parse));
  13.             List<int> challengeList = new List<int>(Console.ReadLine().Split().Select(int.Parse));
  14.  
  15.             while (toolQueue.Count > 0 && substanceStack.Count > 0)
  16.             {
  17.                 int currentTool = toolQueue.Dequeue();
  18.                 int currentSubstance = substanceStack.Pop();
  19.                 int result = currentTool * currentSubstance;
  20.  
  21.                 if (challengeList.Contains(result))
  22.                 {
  23.                     challengeList.Remove(result);
  24.                 }
  25.                 else
  26.                 {
  27.                     currentTool++;
  28.                     toolQueue.Enqueue(currentTool);
  29.  
  30.                     currentSubstance--;
  31.                     if (currentSubstance > 0)
  32.                     {
  33.                         substanceStack.Push(currentSubstance);
  34.                     }
  35.                 }
  36.  
  37.                 if (challengeList.Count == 0)
  38.                 {
  39.                     Console.WriteLine("Harry found an ostracon, which is dated to the 6th century BCE.");
  40.                     break;
  41.                 }
  42.             }
  43.  
  44.             if (challengeList.Count > 0)
  45.             {
  46.                 Console.WriteLine("Harry is lost in the temple. Oblivion awaits him.");
  47.             }
  48.  
  49.             if (toolQueue.Count > 0)
  50.             {
  51.                 Console.WriteLine($"Tools: {string.Join(", ", toolQueue)}");
  52.             }
  53.  
  54.             if (substanceStack.Count > 0)
  55.             {
  56.                 Console.WriteLine($"Substances: {string.Join(", ", substanceStack)}");
  57.             }
  58.  
  59.             if (challengeList.Count > 0)
  60.             {
  61.                 Console.WriteLine($"Challenges: {string.Join(", ", challengeList)}");
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement