Nouvelle version (toujours trop lente)

This commit is contained in:
rick 2021-03-17 22:40:44 +01:00
parent ddf165db95
commit 30271d0a70
Signed by: Rick
GPG key ID: 2B593F087240EE99

View file

@ -2,25 +2,49 @@ basInput$ = "1113222113"
pred$ = "" pred$ = ""
act$ = "" act$ = ""
new$ = "" new$ = ""
k = 0 nb = 0
maxx=peek("screenwidth")-1:maxy=peek("screenheight")-1
clear screen
for i = 0 to 40 for i = 0 to 40
print i, " / 40" print i, " / 40"
for j = 1 to len(basInput$) step k for j = 1 to len(basInput$) step nb
k = 1 print at(0,i) i," / 40 mots | ",j," / ",len(basInput$)," lettres"
act$ = mid$(basInput$, j, 1) act$ = mid$(basInput$, j, 1)
pred$ = act$ if (act$ = mid$(basInput$, j + 1, 1)) then
while pred$ = act$ and (j + k) < len(basInput$) if (act$ = mid$(basInput$, j + 2, 1)) then
pred$ = act$ nb = 3
act$ = mid$(basInput$, j + k, 1) else
k = k + 1 nb = 2
if act$ <> pred$ then
k = k - 1
endif endif
wend else
new$ = new$ + str$(k) + pred$ nb = 1
endif
new$ = new$ + str$(nb) + act$
next j next j
basInput$ = new$ basInput$ = new$
next i 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$) print "La longeur de la chaine finale est ", len(basInput$)