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;
- class LittleJohn
- {
- static void Main()
- {
- string arrowTypePattern = @"\W{1,3}\-{5}\W{1,2}";
- string smallArrowPattern = @">{1}\-{5}\>{1}";
- string mediumArrowPattern = @">{2}\-{5}\>{1}";
- string largeArrowPattern = @">{3}\-{5}\>{2}";
- Regex typeRegex = new Regex(arrowTypePattern);
- Regex smallRegex = new Regex(smallArrowPattern);
- Regex mediumRegex = new Regex(mediumArrowPattern);
- Regex largeRegex = new Regex(largeArrowPattern);
- int largeArrowsCount = 0;
- int mediumArrowsCount = 0;
- int smallArrowsCount = 0;
- for (int i = 0; i < 4; i++)
- {
- string input = Console.ReadLine();
- MatchCollection match = typeRegex.Matches(input);
- if (match.Count > 0)
- {
- foreach (var arrow in match)
- {
- Match largeArrowMatch = largeRegex.Match(arrow.ToString());
- if (largeArrowMatch.Success)
- {
- largeArrowsCount++;
- }
- else
- {
- Match mediumArrowMatch = mediumRegex.Match(arrow.ToString());
- if (mediumArrowMatch.Success)
- {
- mediumArrowsCount++;
- }
- else
- {
- Match smallArrowMatch = smallRegex.Match(arrow.ToString());
- if (smallArrowMatch.Success)
- {
- smallArrowsCount++;
- }
- }
- }
- }
- }
- }
- int theNumbderInDec = 100 * smallArrowsCount + 10 * mediumArrowsCount + largeArrowsCount;
- string theNumberInBinary = Convert.ToString(theNumbderInDec, 2);
- StringBuilder sb = new StringBuilder();
- for (int i = theNumberInBinary.Length - 1; i >= 0; i--)
- {
- sb.Append(theNumberInBinary[i]);
- }
- string combinedNumber = theNumberInBinary + sb.ToString();
- int combinedNumberInDec = Convert.ToInt32(combinedNumber, 2);
- Console.WriteLine(combinedNumberInDec);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement