Advertisement
Aborigenius

BeerPong

Aug 15th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace BeerPong
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.  
  15.             Dictionary<string, Dictionary<string, int>> pong =
  16.                 new Dictionary<string, Dictionary<string, int>>();
  17.  
  18.             while (input != "stop the game")
  19.             {
  20.                 string[] inputTokens = input.Split('|');
  21.  
  22.                 string name = inputTokens[0];
  23.                 string team = inputTokens[1];
  24.                 int points = int.Parse(inputTokens[2]);
  25.  
  26.                 if (!pong.ContainsKey(team))
  27.                 {
  28.                     pong[team] = new Dictionary<string, int>();
  29.                 }
  30.                 if (pong[team].Values.Count == 3)
  31.                 {
  32.                     input = Console.ReadLine();
  33.                     continue;
  34.                 }
  35.                 else
  36.                 {
  37.                     pong[team][name] = points;
  38.                 }
  39.                 input = Console.ReadLine();
  40.             }
  41.             int some = 0;
  42.             //           int TeamSum = pong.Values.Sum(points => points.Values.Sum());
  43.             foreach (var item in pong.Where(players => players.Value.Count == 3)
  44.                 .OrderByDescending((x => x.Value.Values.Sum())))
  45.             {
  46.                 some++;
  47.                 Console.WriteLine($"{some}. {item.Key}; Players:");
  48.                
  49.                 foreach (var player in item.Value.OrderByDescending(points =>
  50.                 points.Value))
  51.                 {
  52.                     Console.WriteLine($"###{player.Key}: {player.Value}");
  53.                 }
  54.                
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement