Advertisement
mastersan12

Deciphering

Apr 13th, 2019
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Text;
  5. using System.Linq;
  6.  
  7.  
  8. namespace Concert
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string textPattern = @"^[d-z{}|#]+$";
  15.             string input = Console.ReadLine();
  16.             string input2 = Console.ReadLine();
  17.             List<string> listOfReplacements = input2.Split(" ").ToList();
  18.             StringBuilder sb = new StringBuilder();
  19.             bool isValid = Regex.IsMatch(input, textPattern);
  20.             if (isValid)
  21.             {
  22.                 foreach (char symbol in input)
  23.                 {
  24.                     char current = (char)(symbol - 3);
  25.                     sb.Append(current);
  26.                 }
  27.  
  28.                 sb.Replace(listOfReplacements[0], listOfReplacements[1]);
  29.             }
  30.  
  31.             else
  32.             {
  33.                 Console.WriteLine("This is not the book you are looking for.");
  34.                 return;
  35.             }
  36.             Console.WriteLine(sb);
  37.            
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement