Advertisement
Prohause

Litle John

Jun 18th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace LittleJohn
  9. {
  10. public class StartUp
  11. {
  12. public static void Main(string[] args)
  13. {
  14. const string pattern = @"(>----->)|(>>----->)|(>>>----->>)";
  15. var regex = new Regex(pattern);
  16. var smallOnes = 0;
  17. var mediumOnes = 0;
  18. var longOnes = 0;
  19.  
  20. for (var i = 0; i < 4; i++)
  21. {
  22. var match = regex.Match(Console.ReadLine());
  23. while (match.Success)
  24. {
  25. if (!match.Groups[1].Value.Equals(""))
  26. {
  27. smallOnes++;
  28. }
  29. else if (!match.Groups[2].Value.Equals(""))
  30. {
  31. mediumOnes++;
  32. }
  33. else if (!match.Groups[3].Value.Equals(""))
  34. {
  35. longOnes++;
  36. }
  37. match = match.NextMatch();
  38. }
  39. }
  40. var decimalOutput = smallOnes.ToString() + mediumOnes + longOnes;
  41. var binary = Convert.ToString(int.Parse(decimalOutput), 2);
  42. binary = binary + string.Join("", binary.Reverse());
  43. var encrypted = Convert.ToInt32(binary, 2);
  44. Console.WriteLine(encrypted);
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement