Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* As input will receive an HTML document as a single string. You need to get the text from all the <p> tags and replace all characters which are not small letters and numbers with a space ' '. After that you must decrypt the text - all letters from a to m are converted to letters from n to z accordingly (a -> n, b -> o, ... m -> z). The letters from n to z are converted to letters from a to m accordingly (n -> a, o -> b, ... z -> m). All multiple spaces should then be replaced by only one space! Print at a single line the decrypted text.*/
- namespace _08.UseYourChainsBuddy
- {
- using System;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- class UseYourChainsBuddy
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- const string pattern = @"<p>(.+?)<\/p>";
- MatchCollection matches = Regex.Matches(text, pattern);
- foreach (StringBuilder sb in from Match match in matches select new StringBuilder(match.Groups[1].Value))
- {
- for (int i = 0; i < sb.Length; i++)
- {
- char symb = sb[i];
- if ((char.IsLetter(symb) && char.IsLower(symb)) || char.IsDigit(symb))
- {
- if (!char.IsLower(symb)) continue;
- int asciiCode = symb;
- asciiCode += (symb < 110) ? 13 : -13;
- sb[i] = (char)asciiCode;
- }
- else
- {
- sb[i] = ' ';
- }
- }
- Regex rgx = new Regex(@"\s+");
- Console.Write(rgx.Replace(sb.ToString(), " "));
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement