Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- public class LittleJohn
- {
- public static void Main()
- {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < 4; i++)
- {
- sb.AppendFormat(" {0}", Console.ReadLine());
- }
- const string ArrowPattern = @"(>>>----->>)|(>>----->)|(>----->)";
- Regex arrowMatcher = new Regex(ArrowPattern);
- var arrows = arrowMatcher.Matches(sb.ToString()).Cast<Match>();
- int largeArrowCount = arrows.Count(match => match.Groups[1].Value != string.Empty);
- int mediumArrowCount = arrows.Count(match => match.Groups[2].Value != string.Empty);
- int smallArrowCount = arrows.Count(match => match.Groups[3].Value != string.Empty);
- string numberAsString = string.Format(
- "{0}{1}{2}",
- smallArrowCount,
- mediumArrowCount,
- largeArrowCount);
- int number = int.Parse(numberAsString);
- string binaryNum = Convert.ToString(number, 2);
- string reversedBinaryNum = new string(binaryNum.Reverse().ToArray());
- string resultAsString = binaryNum + reversedBinaryNum;
- int result = Convert.ToInt32(resultAsString, 2);
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement