Guest User

Untitled

a guest
Jun 26th, 2019
316
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace testyy
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var input = Console.ReadLine().Split(">").ToList();
  12.  
  13. int power = 0;
  14.  
  15. int additionalpower = 0;
  16.  
  17. for (int i = 0; i < input.Count; i++)
  18. {
  19.  
  20. if (input[i].Any(c => char.IsDigit(c)))
  21. {
  22. power = int.Parse(input[i][0] + "");
  23.  
  24. if (power>1 && input[i].Length<2)
  25. {
  26. int oldpower = power;
  27. power = 1;
  28. additionalpower += oldpower - power;
  29. }
  30.  
  31. input[i] = input[i].Substring(power);
  32. if (i==input.Count-1 && additionalpower > 0)
  33. {
  34. input[i] = input[i].Substring(additionalpower);
  35. }
  36. }
  37.  
  38. }
  39. Console.WriteLine(string.Join(">",input));
  40. }
  41.  
  42.  
  43. }
  44.  
  45. }
RAW Paste Data