From 2baf4d1fde668be10343b899b18cd95564b138a5 Mon Sep 17 00:00:00 2001 From: rick Date: Thu, 18 Mar 2021 19:19:26 +0100 Subject: [PATCH] Ajout des 2 parties qui marchent --- jour10/jour10.bs | 50 ----------------------------------------------- jour10/jour10.vbs | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 50 deletions(-) delete mode 100644 jour10/jour10.bs create mode 100644 jour10/jour10.vbs diff --git a/jour10/jour10.bs b/jour10/jour10.bs deleted file mode 100644 index b1cb421..0000000 --- a/jour10/jour10.bs +++ /dev/null @@ -1,50 +0,0 @@ -basInput$ = "1113222113" -pred$ = "" -act$ = "" -new$ = "" -nb = 0 - -maxx=peek("screenwidth")-1:maxy=peek("screenheight")-1 -clear screen - -for i = 0 to 40 - print i, " / 40" - for j = 1 to len(basInput$) step nb - print at(0,i) i," / 40 mots | ",j," / ",len(basInput$)," lettres" - act$ = mid$(basInput$, j, 1) - if (act$ = mid$(basInput$, j + 1, 1)) then - if (act$ = mid$(basInput$, j + 2, 1)) then - nb = 3 - else - nb = 2 - endif - else - nb = 1 - endif - new$ = new$ + str$(nb) + act$ - next j - basInput$ = new$ - next i - -rem ancien code -rem print new$ -rem for i = 0 to 40 -rem print i, " / 40" -rem for j = 1 to len(basInput$) step k -rem k = 1 -rem act$ = mid$(basInput$, j, 1) -rem pred$ = act$ -rem while pred$ = act$ and (j + k) < len(basInput$) -rem pred$ = act$ -rem act$ = mid$(basInput$, j + k, 1) -rem k = k + 1 -rem if act$ <> pred$ then -rem k = k - 1 -rem endif -rem wend -rem new$ = new$ + str$(k) + pred$ -rem next j -rem basInput$ = new$ -rem next i - -print "La longeur de la chaine finale est ", len(basInput$) diff --git a/jour10/jour10.vbs b/jour10/jour10.vbs new file mode 100644 index 0000000..2740078 --- /dev/null +++ b/jour10/jour10.vbs @@ -0,0 +1,44 @@ +Module mainModule + Sub Main() + Const NbIt As Integer = 50 + ' NbOcc à modifier, contient le nombre d’itération à faire' + ' MyInput contient la chaine d’entrée + ' Builder construit la chaine suivante + ' occ est le nombre d’occurence d’un 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