To make the winning code more understandable:
code:
Function BWTDecode($sEncoded, $iOffset)

;Declare the variables
Dim $iStringCounter,$iCounter,$sTransformVector

;Loop for each possible ANSI character
For $iCounter=1 to 255

;Loop for each encoded character
For $iStringCounter=1 to Len($sEncoded)

;If current ANSI = current encoded then
;write down the position of the char (in encoded)
;This way the Transformation vector is determined
If $iCounter=ASC(SubStr($sEncoded,$iStringCounter))

;Use a space as a delimiter
$sTransformVector=$sTransformVector+" "+$iStringCounter

EndIf
Next
Next

;Raise the offset by one; substr starts with 1 and not 0 (array index)
$iOffset=$iOffset+1

;Loop to decode the encoded string
For $iCounter=2 to $iStringCounter

;The output = the encoded string decoded using the offsets
;in the Transformation vector
$BWTDecode=$BWTDecode+SubStr($sEncoded,$iOffset,1)

;Determine next offset
$iOffset=Split($sTransformVector)[$iOffset]
Next
EndFunction

{edit - PM from Howard:
quote:
Nice work documenting the code. You may also want to add that the TransformVector is also zero based like an ARRAY, but when we move to the string "one" base we need to increment the initial offset only. The TransformVector is already artificially high by one because of the initial space in $sTransformVector.

}

[ 01. January 2003, 13:22: Message edited by: MightyR1 ]
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...