aoc-2015/jour10/jour10.bs

51 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-03-09 01:12:18 +00:00
basInput$ = "1113222113"
pred$ = ""
act$ = ""
new$ = ""
2021-03-17 21:40:44 +00:00
nb = 0
maxx=peek("screenwidth")-1:maxy=peek("screenheight")-1
clear screen
2021-03-09 01:12:18 +00:00
for i = 0 to 40
print i, " / 40"
2021-03-17 21:40:44 +00:00
for j = 1 to len(basInput$) step nb
print at(0,i) i," / 40 mots | ",j," / ",len(basInput$)," lettres"
2021-03-09 01:12:18 +00:00
act$ = mid$(basInput$, j, 1)
2021-03-17 21:40:44 +00:00
if (act$ = mid$(basInput$, j + 1, 1)) then
if (act$ = mid$(basInput$, j + 2, 1)) then
nb = 3
else
nb = 2
2021-03-09 01:12:18 +00:00
endif
2021-03-17 21:40:44 +00:00
else
nb = 1
endif
new$ = new$ + str$(nb) + act$
2021-03-09 01:12:18 +00:00
next j
basInput$ = new$
next i
2021-03-17 21:40:44 +00:00
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
2021-03-09 01:12:18 +00:00
print "La longeur de la chaine finale est ", len(basInput$)