kema

UseYourChainsBuddy

Jun 19th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5. public class UseYourChainsBuddy
  6. {
  7.     public static void Main()
  8.     {
  9.         Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
  10.  
  11.         var input = Console.ReadLine();
  12.         var pattern = @"<p>(.*?)<\/p>";
  13.         var regex = new Regex(pattern);
  14.         var matches = regex.Matches(input);
  15.         var output = new List<string>();
  16.  
  17.         foreach (Match  match in matches)
  18.         {
  19.             var textToConvert = match.Groups[1].Value;
  20.             textToConvert = Regex.Replace(textToConvert,@"[^a-z0-9]+", " ");
  21.             var textArr = textToConvert.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
  22.  
  23.  
  24.             for (int i = 0; i < textArr.Length; i++)
  25.             {
  26.                 var newWord = new Queue<char>();
  27.                 var word = textArr[i];
  28.  
  29.                 for (int y = 0; y < word.Length; y++)
  30.                 {
  31.                     if ((int)word[y] >= 97 && (int)word[y] <= 109)
  32.                     {
  33.                         var ch = (char)(((int)word[y]) + 13);
  34.                         newWord.Enqueue(ch);
  35.  
  36.                     }
  37.                     else if ((int)word[y] >= 110 && (int)word[y] <= 122)
  38.                     {
  39.                         var ch = (char)(((int)word[y]) - 13);
  40.                         newWord.Enqueue(ch);
  41.                     }
  42.                     else
  43.                     {
  44.                         newWord.Enqueue(word[y]);
  45.  
  46.                     }
  47.                 }
  48.                 output.Add(string.Join("", newWord));
  49.             }
  50.          
  51.         }
  52.         Console.WriteLine(string.Join(" ",output));
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment