| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Text;
- namespace D10._1
- {
- public class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 1) throw new ArgumentException();
- string input = args[0];
- int tries = 40;
- Apply(ref input, ref tries);
- Console.WriteLine($"The answer is : {input.Length}");
- }
- public static void Apply(ref string input, ref int tries)
- {
- while (tries > 0)
- {
- var ninput = new StringBuilder("");
- int i = 0;
- while (i < input.Length)
- {
- char current = input[i];
- int count = 0;
- while (i < input.Length && input[i] == current)
- {
- count++;
- i++;
- }
- ninput.Append(count);
- ninput.Append(current);
- }
- input = ninput.ToString();
- tries--;
- }
- }
- }
- }
|