1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00
programming-challenges/challenges/look-and-say-sequence-conway/solutions/cs/function/Solution.cs

28 lines
787 B
C#

using System;
namespace Solution
{
class Program
{
static void Main()
{
string line = Console.ReadLine();
string result = "";
for (int index = 0; index < line.Length; index++)
{
int numberOfAppearances = 0;
char valueToSearch = line[index];
int iteration = index;
while (iteration < line.Length && line[iteration] == valueToSearch)
{
numberOfAppearances += 1;
iteration++;
}
result = result + numberOfAppearances.ToString() + valueToSearch;
index += numberOfAppearances - 1;
}
Console.WriteLine(result);
}
}
}