Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Globalization;
- namespace _04MovieTime
- {
- class Program
- {
- static void Main(string[] args)
- {
- string genre = Console.ReadLine();
- string duration = Console.ReadLine();
- Dictionary<string, string> movieTime = new Dictionary<string, string>();
- TimeSpan totalTime = new TimeSpan();
- while (true)
- {
- string command = Console.ReadLine();
- if(command == "POPCORN!")
- {
- break;
- }
- string[] tokens = command.Split("|");
- string name = tokens[0];
- string currGenre = tokens[1];
- int[] spliitedTime = tokens[2].Split(":").Select(int.Parse).ToArray();
- int hours = spliitedTime[0];
- int mins = spliitedTime[1];
- int secs = spliitedTime[2];
- TimeSpan currTime = new TimeSpan(hours, mins, secs);
- totalTime += currTime;
- if(currGenre == genre)
- {
- movieTime.Add(name, tokens[2]);
- }
- }
- if(duration == "Short")
- {
- foreach (var kvp in movieTime.OrderBy(x=>x.Value).ThenBy(x=>x.Key))
- {
- string wife = Console.ReadLine();
- if(wife == "Yes")
- {
- Console.WriteLine(kvp.Key);
- Console.WriteLine($"We're watching {kvp.Key} - {kvp.Value}");
- break;
- }
- else
- {
- Console.WriteLine(kvp.Key);
- }
- }
- }
- else
- {
- foreach (var kvp in movieTime.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- string wife = Console.ReadLine();
- if (wife == "Yes")
- {
- Console.WriteLine(kvp.Key);
- Console.WriteLine($"We're watching {kvp.Key} - {kvp.Value}");
- break;
- }
- else
- {
- Console.WriteLine(kvp.Key);
- }
- }
- }
- Console.WriteLine($"Total Playlist Duration: {totalTime}");
- }
- }
- }
Add Comment
Please, Sign In to add comment