Advertisement
angelneychev

Untitled

Apr 6th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _02._Deciphering
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.             var replaceString = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
  12.             Regex regex = new Regex(@"[d-z#|{}]+");
  13.             string result = string.Empty;
  14.             var match = regex.Match(input);
  15.  
  16.             if (input.Length != match.Length)
  17.             {
  18.                 Console.WriteLine("This is not the book you are looking for.");
  19.             }
  20.             else
  21.             {
  22.                 for (int i = 0; i < match.Length; i++)
  23.                 {
  24.                     result += ((char)(input[i] - 3));
  25.                 }
  26.             }
  27.  
  28.             while (result.Contains(replaceString[0]))
  29.             {
  30.                 result = result.Replace(replaceString[0], replaceString[1]);
  31.             }
  32.             Console.WriteLine(result);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement