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.RegularExpressions;
- namespace Deciphering
- {
- class Program
- {
- public static void Main()
- {
- var book = Console.ReadLine();
- var bookPattern = @"^[d-z{}|#]+$";
- var bookMatch = Regex.Match(book, bookPattern);
- if (bookMatch.Success)
- {
- var validBook = bookMatch.ToString();
- var decriptedStr = string.Empty;
- for (int i = 0; i < validBook.Length; i++)
- {
- var currentlater = validBook[i];
- int asciiCode = currentlater - 3;
- var newLetter = (char)asciiCode;
- decriptedStr += newLetter;
- }
- var substrings = Console.ReadLine()
- .Split();
- var finalString = decriptedStr.Replace(substrings[0], substrings[1]);
- Console.WriteLine(finalString);
- }
- else
- {
- Console.WriteLine("This is not the book you are looking for.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement