1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-11-09 22:08:58 +01:00

feat(solutions): add look-and-say-sequence-conway/cs/function

This commit is contained in:
Divlo 2021-11-30 16:15:25 +01:00
parent 46e6f2d7ca
commit b3fb594865
No known key found for this signature in database
GPG Key ID: 6F24DA54DA3967CF
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# look-and-say-sequence-conway/cs/function
Created by [@Divlo](https://github.com/Divlo) on 30 November 2021.

View File

@ -0,0 +1,27 @@
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() + line[index];
index += numberOfAppearances - 1;
}
Console.WriteLine(result);
}
}
}