Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
mainwin 100 20
|
||||
|
||||
'In$ ="aaaaaaaaaaaaaaaaaccbbbbbbbbbbbbbbba" ' testing...
|
||||
In$ ="WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
|
||||
' Out$= "12W1B12W3B24W1B14W"
|
||||
|
||||
Out$ =Encoded$( In$)
|
||||
Inv$ =Decoded$( Out$)
|
||||
|
||||
print " Supplied string ="; In$
|
||||
Print " RLE version ="; Out$
|
||||
print " Decoded back to ="; Inv$
|
||||
|
||||
end
|
||||
|
||||
function Encoded$( k$)
|
||||
r$ =""
|
||||
r =1
|
||||
for i =2 to len( k$)
|
||||
prev$ =mid$( k$, i -1, 1)
|
||||
c$ =mid$( k$, i, 1)
|
||||
if c$ =prev$ then ' entering a run of this character
|
||||
r =r +1
|
||||
else ' it occurred only once
|
||||
r$ =r$ +str$( r) +prev$
|
||||
r =1
|
||||
end if
|
||||
next i
|
||||
r$ =r$ +str$( r) +c$
|
||||
Encoded$ =r$
|
||||
end function
|
||||
|
||||
function Decoded$( k$)
|
||||
r$ =""
|
||||
v =0
|
||||
for i =1 to len( k$)
|
||||
i$ =mid$( k$, i, 1)
|
||||
if instr( "0123456789", i$) then
|
||||
v =v *10 +val( i$)
|
||||
else
|
||||
for m =1 to v
|
||||
r$ =r$ +i$
|
||||
next m
|
||||
v =0
|
||||
end if
|
||||
next i
|
||||
Decoded$ =r$
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue