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.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace _02.HornetComm
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine();
- Dictionary<string, List<string>> privateMessages = new Dictionary<string, List<string>>();
- Dictionary<string, string> broadcast = new Dictionary<string, string>();
- string patternMessage = @"\b([0-9]+) <-> ([^\d\W]+\b)";
- string patternBroadcast = @"^([^\d]+) <-> ([A-Za-z0-9]+)";
- while (input != "Hornet is Green")
- {
- foreach (Match m in Regex.Matches(input, patternMessage))
- {
- if (!privateMessages.ContainsKey(m.Groups[1].Value))
- {
- privateMessages.Add(m.Groups[1].Value, new List<string>());
- privateMessages[m.Groups[1].Value].Add(m.Groups[2].Value);
- }
- else
- {
- privateMessages[m.Groups[1].Value].Add(m.Groups[2].Value);
- }
- }
- foreach (Match b in Regex.Matches(input, patternBroadcast))
- {
- broadcast.Add(b.Groups[1].Value, b.Groups[2].Value);
- }
- var reversed = string.Empty;
- foreach (var item in privateMessages)
- {
- reversed = item.Key.ToString().Reverse().ToString();
- }
- input = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement