Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- public class Program
- {
- public static void Main()
- {
- var names = Console.ReadLine().Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray().OrderBy(x=>x);
- var list = new List<string>();
- foreach (var name in names)
- {
- list.Clear();
- var rg = new Regex(@"(?<=\d|\w)(-\d+.(?=\d)\d*|-\d+)|(\d+.(?=\d)\d*|\d+)");
- var matches = rg.Matches(name);
- foreach (Match match in matches)
- {
- var a = match.Groups[1].Value;
- var a1 = match.Groups[2].Value;
- if(a != string.Empty)
- {
- list.Add(a);
- }
- else
- {
- list.Add(a1);
- }
- }
- var letterSum = 0;
- var digitSum = list.Select(double.Parse).Sum();
- for (int i = 0; i < name.Length; i++)
- {
- if (char.IsLetter(name[i]))
- {
- letterSum += name[i];
- }
- else if (name[i] =='/')
- {
- digitSum /=2;
- }
- else if (name[i] == '*')
- {
- digitSum *= 2;
- }
- }
- Console.WriteLine("{0} - {1} health, {2:f2} damage", name, letterSum, digitSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement