using System; using System.Collections.Generic; using System.Linq; namespace BinaryDigitsCount { class MainClass { public static void Main(string[] args) { string[] rooms = Console.ReadLine().Split('|').ToArray(); int health = 100; int totalBitCoins = 0; for (int i = 0; i < rooms.Length; i++) { string[] currRoom = rooms[i].Split().ToArray(); string commands = currRoom[0]; int points = int.Parse(currRoom[1]); if (commands == "chest") { Console.WriteLine($"You found {points} bitcoins."); totalBitCoins += points; } else if (commands == "potion") { int currentHealth = health; if (health + points > 100) { health = 100; int diff = health - currentHealth; Console.WriteLine($"You healed for {diff} hp."); Console.WriteLine($"Current health: {health}"); } else { health += points; Console.WriteLine($"You healed for {points} hp."); Console.WriteLine($"Current health: {health}"); } } else { health -= points; if (health > 0) { Console.WriteLine($"You slayed {commands}"); } else if (health <= 0) { Console.WriteLine($"You died! Killed by {commands}."); Console.WriteLine($"Best room: {i + 1}"); break; } } } if(health > 0) { Console.WriteLine("You've made it!"); Console.WriteLine($"Bitcoins: {totalBitCoins}"); Console.WriteLine($"Health: {health}"); } } } }