aoc-2015/jour10/jour10.vbs

45 lines
1.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Module mainModule
Sub Main()
Const NbIt As Integer = 50
' NbOcc à modifier, contient le nombre ditération à faire'
' MyInput contient la chaine dentrée
' Builder construit la chaine suivante
' occ est le nombre doccurence dun nombre
' i et j sont des itérateurs pour le nombre de fois à faire
' le programme et le parcours de la chaine
' actChar est le caractère courant
Dim MyInput As String = "1113222113"
Dim Builder As New System.Text.StringBuilder
Dim occ As Integer
Dim i As Integer
Dim j As Integer = 0
Dim actChar as Char
Do While i < NbIt
Builder.Clear()
Console.WriteLine("Etape numero : {0}", i)
j = 1
Do
occ = 1
actChar = GetChar(MyInput, j)
Try
If GetChar(MyInput, j + 1) = actChar Then
If GetChar(MyInput, j + 2) = actChar Then
occ = 3
Else
occ = 2
End if
End If
Catch
End Try
Builder.Append(occ & actChar)
j += occ
Loop Until j > Len(MyInput)
i += 1
MyInput = Builder.ToString()
Loop
Console.WriteLine("Le resultat est {0}", Len(MyInput))
End Sub
End Module