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;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace LittleJohn
- {
- public class StartUp
- {
- public static void Main(string[] args)
- {
- const string pattern = @"(>----->)|(>>----->)|(>>>----->>)";
- var regex = new Regex(pattern);
- var smallOnes = 0;
- var mediumOnes = 0;
- var longOnes = 0;
- for (var i = 0; i < 4; i++)
- {
- var match = regex.Match(Console.ReadLine());
- while (match.Success)
- {
- if (!match.Groups[1].Value.Equals(""))
- {
- smallOnes++;
- }
- else if (!match.Groups[2].Value.Equals(""))
- {
- mediumOnes++;
- }
- else if (!match.Groups[3].Value.Equals(""))
- {
- longOnes++;
- }
- match = match.NextMatch();
- }
- }
- var decimalOutput = smallOnes.ToString() + mediumOnes + longOnes;
- var binary = Convert.ToString(int.Parse(decimalOutput), 2);
- binary = binary + string.Join("", binary.Reverse());
- var encrypted = Convert.ToInt32(binary, 2);
- Console.WriteLine(encrypted);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement