Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- class Program
- {
- static void Main(string[] args)
- {
- #if DEBUG
- Console.SetIn(new StreamReader("../../../input.txt"));
- #endif
- string[] houses = { "Gryffindor", "Slytherin", "Ravenclaw", "Hufflepuff" };
- int[] studentCounts = { 0, 0, 0, 0 };
- int studentCount = int.Parse(Console.ReadLine());
- for (int count = 0; count < studentCount; count++)
- {
- string studentName = Console.ReadLine();
- int asciiSum = GetAsciiSum(studentName);
- int remainder = asciiSum % 4;
- string[] studentNames = studentName.Split();
- Console.WriteLine($"{houses[remainder]} {asciiSum}{studentNames[0][0]}{studentNames[1][0]}");
- studentCounts[remainder]++;
- }
- Console.WriteLine();
- for (int index = 0; index < 4; index++)
- Console.WriteLine($"{houses[index]}: {studentCounts[index]}");
- }
- private static int GetAsciiSum(string studentName)
- {
- int sum = 0;
- foreach (var character in studentName)
- if (character != ' ')
- sum += character;
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment