Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
62
Task/Run-length-encoding/TSE-SAL/run-length-encoding.tse
Normal file
62
Task/Run-length-encoding/TSE-SAL/run-length-encoding.tse
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
STRING PROC FNStringGetDecodeStringCharacterEqualCountS( STRING inS )
|
||||
STRING s1[255] = ""
|
||||
STRING s2[255] = ""
|
||||
STRING s3[255] = ""
|
||||
STRING s4[255] = ""
|
||||
INTEGER I = 0
|
||||
INTEGER J = 0
|
||||
INTEGER K = 0
|
||||
INTEGER L = 0
|
||||
K = Length( inS )
|
||||
I = 1 - 1
|
||||
REPEAT
|
||||
J = 1 - 1
|
||||
s3 = ""
|
||||
REPEAT
|
||||
I = I + 1
|
||||
J = J + 1
|
||||
s1 = SubStr( inS, I, 1 )
|
||||
s3 = s3 + s1
|
||||
s4 = SubStr( inS, I + 1, 1 )
|
||||
UNTIL ( NOT ( s4 IN '0'..'9' ) )
|
||||
FOR L = 1 TO Val( s3 )
|
||||
s2 = s2 + s4
|
||||
ENDFOR
|
||||
I = I + 1
|
||||
UNTIL ( I >= ( K - 1 ) )
|
||||
RETURN( s2 )
|
||||
END
|
||||
//
|
||||
STRING PROC FNStringGetEncodeStringCharacterEqualCountS( STRING inS )
|
||||
STRING s1[255] = ""
|
||||
STRING s2[255] = ""
|
||||
INTEGER I = 0
|
||||
INTEGER J = 0
|
||||
INTEGER K = 0
|
||||
K = Length( inS )
|
||||
I = 1 - 1
|
||||
REPEAT
|
||||
J = 1 - 1
|
||||
REPEAT
|
||||
I = I + 1
|
||||
J = J + 1
|
||||
s1 = SubStr( inS, I, 1 )
|
||||
UNTIL ( NOT ( SubStr( inS, I + 1, 1 ) == s1 ) )
|
||||
s2 = s2 + Str( J ) + s1
|
||||
UNTIL ( I >= ( K - 1 ) )
|
||||
RETURN( s2 )
|
||||
END
|
||||
//
|
||||
STRING PROC FNStringGetEncodeDecodeStringCharacterEqualCountS( STRING inS )
|
||||
STRING s1[255] = FNStringGetEncodeStringCharacterEqualCountS( inS )
|
||||
STRING s2[255] = FNStringGetDecodeStringCharacterEqualCountS( s1 )
|
||||
RETURN( s2 )
|
||||
END
|
||||
//
|
||||
PROC Main()
|
||||
STRING s1[255] = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
|
||||
STRING s2[255] = ""
|
||||
IF ( NOT ( Ask( "string: get: encode: decode: string: character: equal: count: inS = ", s1, _EDIT_HISTORY_ ) ) AND ( Length( s1 ) > 0 ) ) RETURN() ENDIF
|
||||
s2 = FNStringGetEncodeDecodeStringCharacterEqualCountS( s1 )
|
||||
Warn( "equal strings if result is 1", ",", " ", "and the result is", ":", " ", s1 == s2 )
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue