Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace Deciphering
  7. {
  8. class Program
  9. {
  10. public static void Main()
  11. {
  12. var book = Console.ReadLine();
  13. var bookPattern = @"^[d-z{}|#]+$";
  14. var bookMatch = Regex.Match(book, bookPattern);
  15.  
  16. if (bookMatch.Success)
  17. {
  18. var validBook = bookMatch.ToString();
  19. var decriptedStr = string.Empty;
  20.  
  21. for (int i = 0; i < validBook.Length; i++)
  22. {
  23. var currentlater = validBook[i];
  24. int asciiCode = currentlater - 3;
  25. var newLetter = (char)asciiCode;
  26. decriptedStr += newLetter;
  27. }
  28.  
  29. var substrings = Console.ReadLine()
  30. .Split();
  31. var finalString = decriptedStr.Replace(substrings[0], substrings[1]);
  32.  
  33. Console.WriteLine(finalString);
  34. }
  35. else
  36. {
  37. Console.WriteLine("This is not the book you are looking for.");
  38. }
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement