Advertisement
Guest User

littlejohn

a guest
Jun 3rd, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. public class LittleJohn
  5. {
  6. private static void Main()
  7. {
  8. string[] arrows = { ">>>----->>", ">>----->", ">----->" };
  9. int[] counts = new int[3]; // 0 -> small, 1 -> medium, 2 -> big
  10. for (int i = 0; i < 4; i++)
  11. {
  12. string line = Console.ReadLine();
  13. for (int j = 0, k = 2; j < arrows.Length; j++, k--)
  14. {
  15. string arrow = arrows[j];
  16. int index = line.IndexOf(arrow);
  17. while (index > -1)
  18. {
  19. string firstPart = line.Substring(0, index); // before the arrow
  20. int lastIndex = index + arrow.Length;
  21. string secondPart = line.Substring(lastIndex, line.Length - lastIndex); // after the arrow
  22. line = firstPart + "&" + secondPart; // the line becomes -> before arrow + special symbol + after the arrow, the arrow is effectively replaced
  23. index = line.IndexOf(arrow); // check if there are more arrows from this type left
  24. counts[k]++;
  25. }
  26. }
  27. }
  28.  
  29. string binary = Convert.ToString(long.Parse(string.Join("", counts)), 2);
  30. char[] reversed = binary.ToCharArray();
  31. Array.Reverse(reversed);
  32.  
  33. Console.WriteLine(Convert.ToInt64(binary + string.Join("", reversed), 2));
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement