Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using System.Linq;
- namespace SantasSecretHelper
- {
- class Program
- {
- static void Main(string[] args)
- {
- int key = int.Parse(Console.ReadLine());
- string message = string.Empty;
- var dictNameAndBehaviour = new Dictionary<string, string>();
- while((message=Console.ReadLine())!="end")
- {
- string decryptMessage = string.Empty;
- for (int i = 0; i < message.Length; i++)
- {
- int decryptValue = message[i] - key;
- decryptMessage += (char)decryptValue;
- }
- Regex regexForNameAndBehaviour = new Regex(@"@(?<name>[A-Za-z]+(?![@\-!:>]))[^@\-!:>]*!(?<behaviour>G|N)!");
- MatchCollection matchNameAndBehaviour = regexForNameAndBehaviour.Matches(decryptMessage);
- if (regexForNameAndBehaviour.IsMatch(decryptMessage))
- {
- string name = matchNameAndBehaviour[0].Groups["name"].Value;
- string behaviour = matchNameAndBehaviour[0].Groups["behaviour"].Value;
- dictNameAndBehaviour[name] = behaviour;
- }
- }
- var dictonaryWihtGoodChildren = dictNameAndBehaviour.Where(x => x.Value == "G");
- foreach (var kvp in dictonaryWihtGoodChildren )
- {
- string name = kvp.Key;
- Console.WriteLine(name);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement