Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ExamPreparation
- {
- class Program
- {
- static void Main(string[] args)
- {
- string inputInformation = string.Empty;
- Dictionary<string, Dictionary<string, int>> boysDatabase = new Dictionary<string, Dictionary<string, int>>();
- while ((inputInformation = Console.ReadLine()) != "Make a decision already!")
- {
- string[] boyInfo = inputInformation.Split(" ", StringSplitOptions.RemoveEmptyEntries);
- string boyName = boyInfo[0];
- if ((boyInfo.Contains("does") && boyInfo.Contains("Gyubek!")) == false)
- {
- string trait = boyInfo[1];
- int traitValue = int.Parse(boyInfo[2]);
- bool isNegativeBoy = trait.Equals("Greedy") || trait.Equals("Rude") || trait.Equals("Dumb");
- if (isNegativeBoy == false) // Good boy.
- {
- switch (trait)
- {
- case "Kind":
- traitValue *= 2;
- break;
- case "Handsome":
- traitValue *= 3;
- break;
- case "Smart":
- traitValue *= 5;
- break;
- }
- }
- else
- {
- traitValue -= (traitValue * 2);
- }
- if (boysDatabase.ContainsKey(boyName) == false)
- {
- boysDatabase.Add(boyName, new Dictionary<string, int>());
- boysDatabase[boyName].Add(trait, traitValue);
- }
- else
- {
- if (boysDatabase[boyName].ContainsKey(trait) == false)
- {
- boysDatabase[boyName].Add(trait, traitValue);
- }
- else
- {
- int oldTraitValue = boysDatabase[boyName][trait];
- if(traitValue > oldTraitValue)
- {
- boysDatabase[boyName][trait] = traitValue;
- }
- }
- }
- }
- else if (boysDatabase.ContainsKey(boyName))
- {
- List<string> positiveTraits = new List<string>();
- foreach (var gyubekBoy in boysDatabase[boyName])
- {
- if ((gyubekBoy.Key.Equals("Greedy") || gyubekBoy.Key.Equals("Rude") || gyubekBoy.Key.Equals("Dumb")) == false)
- {
- positiveTraits.Add(gyubekBoy.Key);
- }
- }
- for (int i = 0; i < positiveTraits.Count; i++)
- {
- boysDatabase[boyName].Remove(positiveTraits[i]);
- }
- }
- }
- foreach (var name in boysDatabase.OrderByDescending(x => x.Value.Select(y => y.Value).FirstOrDefault()).ThenBy(z => z.Key))
- {
- int totalTraitValue = boysDatabase[name.Key].Values.Sum();
- Console.WriteLine($"# {name.Key}: {totalTraitValue} ");
- foreach (var trait in name.Value.OrderByDescending(x => x.Value).ThenBy(y => y.Key))
- {
- Console.WriteLine($"!!! {trait.Key} -> {trait.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement