Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- class NetherRealms
- {
- static void Main()
- {
- var demons = Console.ReadLine().Split(',').Select(x => x.Trim()).ToArray();
- Array.Sort(demons);
- foreach (var demon in demons)
- {
- var name = Regex.Matches(demon, @"[^/\*\d\.+-]").Cast<Match>().Select(x => (int)(x.Value[0])).ToArray();
- var health = name.Sum();
- var asterisks = demon.Count(x => x == '*');
- var slashes = demon.Count(x => x == '/');
- var numbers = Regex.Matches(demon, @"-?\d+\.?\d*").Cast<Match>().Select(x => double.Parse(x.Value)).ToArray();
- var damage = numbers.Sum() * Math.Pow(2, asterisks) / Math.Pow(2, slashes);
- Console.WriteLine($"{demon} - {health} health, {damage:f2} damage");
- }
- }
- }
Add Comment
Please, Sign In to add comment