Advertisement
blazarow09

Untitled

Jun 12th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ImmuneSystem
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var line = Console.ReadLine();
  12.  
  13.             var immuneSystem = new List<string>();
  14.  
  15.             double startHealth = double.Parse(line);
  16.             double health = double.Parse(line);
  17.  
  18.             while (true)
  19.             {
  20.                 int virusStrength = 0;
  21.                 int virStr = 0;
  22.                 int timeToDefeatInSec = 0;
  23.  
  24.                 line = Console.ReadLine();
  25.  
  26.                 if (line == "end")
  27.                 {
  28.                     health = health * 0.20 + health;
  29.                     Console.WriteLine($"Final Health: {Math.Abs(health):f0}");
  30.                     break;
  31.                 }
  32.  
  33.                 if (!immuneSystem.Contains(line))
  34.                 {
  35.                     immuneSystem.Add(line);
  36.  
  37.                     foreach (var letter in line)
  38.                     {
  39.                         var virus = letter;
  40.                         virusStrength += virus;
  41.                         virStr = virusStrength / 3;
  42.                         timeToDefeatInSec = virStr * line.Length;
  43.                     }
  44.                    
  45.                     health = health * 0.20 + health;
  46.  
  47.                     if (health > 0)
  48.                     {
  49.                        
  50.                         if (health > startHealth)
  51.                         {
  52.                             health = startHealth;
  53.                         }
  54.  
  55.                         health = health - timeToDefeatInSec;
  56.  
  57.                         Console.WriteLine($"Virus {line}: {virStr:f0} => {timeToDefeatInSec:f0} seconds");
  58.                         Console.WriteLine($"{line} defeated in {timeToDefeatInSec / 60:f0}m {timeToDefeatInSec % 60:f0}s.");
  59.                         Console.WriteLine($"Remaining health: {Math.Abs(health):f0}");
  60.                     }
  61.  
  62.                 }
  63.                 else if (immuneSystem.Contains(line))
  64.                 {
  65.  
  66.                     foreach (var letter in line)
  67.                     {
  68.                         var virus = letter;
  69.                         virusStrength += virus;
  70.                         virStr = virusStrength / 3;
  71.                         timeToDefeatInSec = (virStr * line.Length) /3;
  72.                     }
  73.                    
  74.                     health = health * 0.20 + health;
  75.  
  76.                     if (health > 0)
  77.                     {
  78.                         if (health > startHealth)
  79.                         {
  80.                             health = startHealth;
  81.                         }
  82.  
  83.                        health = health - timeToDefeatInSec;
  84.  
  85.                         Console.WriteLine($"Virus {line}: {virStr:f0} => {timeToDefeatInSec:f0} seconds");
  86.                         Console.WriteLine($"{line} defeated in {timeToDefeatInSec / 60:f0}m {timeToDefeatInSec % 60:f0}s.");
  87.                         Console.WriteLine($"Remaining health: {Math.Abs(health):f0}");
  88.                     }
  89.                 }
  90.             }
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement