Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Globalization;
- namespace _08.Mentor_Group
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- SortedDictionary<string, List<DateTime>> mentorDates = new SortedDictionary<string, List<DateTime>>();
- Dictionary<string, List<string>> mentorComments = new Dictionary<string, List<string>>();
- List<string> inputData = new List<string>();
- string username = string.Empty;
- while (input != "end of dates")
- {
- inputData = input.Split(' ', ',').ToList();
- username = inputData[0];
- if (!mentorDates.ContainsKey(username))
- {
- mentorDates[username] = new List<DateTime>();
- }
- inputData.RemoveAt(0);
- for (int i = 0; i < inputData.Count; i++)
- {
- mentorDates[username].Add(DateTime.ParseExact(inputData[i], "dd/MM/yyyy", CultureInfo.InvariantCulture));
- }
- input = Console.ReadLine();
- }
- input = Console.ReadLine();
- while (input != "end of comments")
- {
- inputData = input.Split('-').ToList();
- username = inputData[0];
- if (!mentorDates.ContainsKey(username))
- {
- input = Console.ReadLine();
- continue;
- }
- if (!mentorComments.ContainsKey(username))
- {
- mentorComments[username] = new List<string>();
- }
- mentorComments[username].Add(inputData[1]);
- input = Console.ReadLine();
- }
- foreach (var item in mentorDates)
- {
- if (item.Value.Count != 0)
- {
- Console.WriteLine(item.Key);
- Console.WriteLine("Comments:");
- if (mentorComments.ContainsKey(item.Key))
- {
- foreach (var comment in mentorComments[item.Key])
- {
- Console.WriteLine($"- {comment}");
- }
- }
- }
- else
- {
- continue;
- }
- Console.WriteLine("Dates attended:");
- foreach (var date in mentorDates[item.Key].OrderBy(x => x))
- {
- string dateString = date.ToString("dd/MM/yyyy");
- Console.WriteLine($"-- {dateString}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement