Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace LittleJohn
- {
- using System;
- using System.Collections.Generic;
- using System.Text;
- public class Startup
- {
- public static void Main()
- {
- string[] arrowTypes = new string[]
- {
- ">>>----->>",
- ">>----->",
- ">----->",
- };
- int inputLines = 4;
- for (int currInputLine = 0; currInputLine < inputLines; currInputLine++)
- {
- string inputLine = Console.ReadLine();
- for (int currArrow = 0; currArrow < arrowTypes.Length; currArrow++)
- {
- string arrow = arrowTypes[currArrow];
- int countOfCurrArrowType = 0;
- int indexOfArrow = inputLine.IndexOf(arrow);
- while (indexOfArrow != -1)
- {
- countOfCurrArrowType++;
- indexOfArrow = inputLine.IndexOf(arrow, indexOfArrow + 1);
- }
- inputLine = inputLine.Replace(arrow, "REPLACED");
- ArrowCounter.AddArrows(currArrow, countOfCurrArrowType);
- }
- }
- string specialBinaryNumber = NumberConverter.ConvertToSpecialBinary(ArrowCounter.SpecialNumber);
- Console.WriteLine(NumberConverter.ConvertToInt64FromSpecialBinary(specialBinaryNumber));
- }
- }
- public static class NumberConverter
- {
- public static string ConvertToSpecialBinary(int number)
- {
- StringBuilder result = new StringBuilder(Convert.ToString(number, 2));
- for (int currSymbol = result.Length - 1; currSymbol >= 0; currSymbol--)
- {
- result.Append(result[currSymbol]);
- }
- return result.ToString();
- }
- public static long ConvertToInt64FromSpecialBinary(string specialBinary)
- {
- return Convert.ToInt64(specialBinary, 2);
- }
- }
- public static class ArrowCounter
- {
- private static Dictionary<ArrowType, int> arrowsCount = new Dictionary<ArrowType, int>
- {
- [ArrowType.Large] = 0,
- [ArrowType.Medium] = 0,
- [ArrowType.Small] = 0
- };
- public static int SpecialNumber
- {
- get
- {
- return arrowsCount[ArrowType.Small] * 100 +
- arrowsCount[ArrowType.Medium] * 10 +
- arrowsCount[ArrowType.Large];
- }
- }
- public static void AddArrows(int indexOfArrowType, int countOfArrowType)
- {
- arrowsCount[(ArrowType)indexOfArrowType] += countOfArrowType;
- }
- }
- public enum ArrowType
- {
- Large,
- Medium,
- Small
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement