Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp177
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> pointsPerPerson = new Dictionary<string, int>();
- int numOfNewcomers = int.Parse(Console.ReadLine());
- int sumName = 0;
- int peopleInGf = 0;
- int peopleInRev = 0;
- int peopleInHuf = 0;
- int peopleInSl = 0;
- for (int i = 0; i < numOfNewcomers; i++)
- {
- string[] name = Console.ReadLine().Split(' ');
- string firstName = name[0];
- char firstInitial = firstName[0];
- string secondName = name[1];
- char secondInitial = secondName[0];
- string fullName = firstName + secondName;
- int fullNameLength = fullName.Length;
- for (int j = 'a'; j <= 'z'; j++)
- {
- for (int k = 0; k < fullNameLength; k++)
- {
- if (fullName[k] == j)
- {
- sumName += j;
- }
- }
- }
- for (int m = 'A'; m <= 'Z'; m++)
- {
- if (firstInitial == m && secondInitial == m)
- {
- sumName += 2 * m;
- }
- else if (firstInitial == m || secondInitial == m)
- {
- sumName += m;
- }
- }
- for (int k = 'a'; k <= 'z'; k++)
- {
- if (firstInitial == k && secondInitial == k)
- {
- sumName += 2 * k;
- }
- else if (firstInitial == k || secondInitial == k)
- {
- sumName += k;
- }
- }
- fullName = firstName + " " + secondName;
- pointsPerPerson.Add(fullName, sumName);
- sumName = 0;
- }
- foreach (var item in pointsPerPerson)
- {
- string[] name = item.Key.Split(' ');
- string firstName = name[0];
- char firstInitial = firstName[0];
- string secondName = name[1];
- char secondInitial = secondName[0];
- if (item.Value % 4 == 0)
- {
- Console.WriteLine($"Gryffindor {item.Value}{firstInitial}{secondInitial}");
- peopleInGf++;
- }
- else if (item.Value % 4 == 1)
- {
- Console.WriteLine($"Slytherin {item.Value}{firstInitial}{secondInitial}");
- peopleInSl++;
- }
- else if (item.Value % 4 == 2)
- {
- Console.WriteLine($"Ravenclaw {item.Value}{firstInitial}{secondInitial}");
- peopleInRev++;
- }
- else if (item.Value % 4 == 3)
- {
- Console.WriteLine($"Hufflepuff {item.Value}{firstInitial}{secondInitial}");
- peopleInHuf++;
- }
- }
- Console.WriteLine();
- Console.WriteLine($"Gryffindor: {peopleInGf}");
- Console.WriteLine($"Slytherin: {peopleInSl}");
- Console.WriteLine($"Ravenclaw: {peopleInRev}");
- Console.WriteLine($"Hufflepuff: {peopleInHuf}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement