Page 1 of 3 123>
Topic Options
#97323 - 2002-12-29 08:57 PM KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
KiXtart
KiXtart Version = 4.20 Beta 1
KiXGolf Script = kixgolf_bwt2.kix

Computer
OS = Windows 2000 Professional
CPU = Intel Pentium III
Speed = 848 MHz

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Burrows-Wheeler Transform
Start (Date/Time) = 2002/12/29 14:57:57
Finish (Date/Time) = 2002/12/29 14:58:04
String Length = 749
KiXGolf Result = passed
KiXGolf Score = 193
code:
function BWTDecode($s, $)
dim $b,$c,$d
for $c=1 to 255
for $b=1 to len($s)
if $c=asc(substr($s,$b,1))
$d=$d+" "+$b
endif
next
next
$=$+1
for $c=2 to $b
$BWTDecode=$BWTDecode+substr($s,$,1)
$=split($d)[$]
next
endfunction

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#97324 - 2002-12-29 09:01 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Very well done Howard. I personally think that NoVarsInString should NOT have been enabled for kixgolf - after all according to the rules ALL valid Kixtart syntax is allowed ... in which case your score should be 191 !!!

-Shawn

Top
#97325 - 2002-12-29 10:00 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Howard,

we were scripting in the same direction...

Again Congratulations

quote:


KiXtart
KiXtart Version = 4.20 Beta 1
KiXGolf Script = kixgolf_bwt.kix

Computer
OS = Windows XP Professional
CPU = Intel Pentium II
Speed = 400 MHz

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Burrows-Wheeler Transform
Date & Time = 2002/12/29 01:16:25
KiXGolf Result = passed
KiXGolf Score = 197
String length = 749
Elapsed time = 11346 msec


Thank you for participating in KiXtart Golf!

code:
Function BWTDecode($e,$o)
Dim $,$v,$i
For $i=0 to 255
For $=1 to Len($e)
If ASC(SubStr($e,$))=$i
$v=$v+' '+($-1)
EndIf
Next
Next
$=''
For $i=1 to Len($e)
$=$+SubStr($e,1+$o,1)
$o=Split($v)[1+$o]
Next
$BWTDecode=$
EndFunction

_________________________
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...

Top
#97326 - 2002-12-29 10:07 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
One of my previous versions was remarkably close to yours, Patrick.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#97327 - 2002-12-29 10:12 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Wow,nice code guys!

For what it's worth, here's what I have.

code:
function BWTDecode($s, $o)
dim $i,$j,$m
$m = len($s)
dim $[$m]
for $i = 1 to $m
$j=$i
while substr($s,$i,1) < substr($s,$[$j-1],1)
$[$j] = $[$j-1]
$j=$j-1
loop
$[$j]=$i
next
for $j=1 to $m
$BWTDecode = $BWTDecode + substr($s,$o+1,1)
$o=$[$o+1]-1
next
endfunction

_________________________
Eric

Top
#97328 - 2002-12-29 10:12 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
This is fase 2 isn't it... Well then:

quote:


KiXtart
KiXtart Version = 4.20 Beta 1
KiXGolf Script = kixgolf_bwt.kix

Computer
OS = Windows XP Professional
CPU = Intel Pentium II
Speed = 400 MHz

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Burrows-Wheeler Transform
Date & Time = 2002/12/29 22:15:32
KiXGolf Result = passed
KiXGolf Score = 191
String length = 749
Elapsed time = 11507 msec


Thank you for participating in KiXtart Golf!

Using some of Howards and some of mine...

In Howards script, kill the ,1 in the first substr...
_________________________
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...

Top
#97329 - 2002-12-29 10:13 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I just saw that too. I was testing because I did not believe it. You beat me to the post.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#97330 - 2002-12-29 10:14 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
[Big Grin]

I liked your trick to reuse the $b and not len($s) again...
_________________________
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...

Top
#97331 - 2002-12-29 10:21 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
This is the super-fast one I was working on ... its basically the kixtart interpretation of the Burrows-Wheeler algorithm described in their original paper ... its fast because there is no need for a sort (score=267):

code:
function bwtdecode($s, $x)

dim $,$j,$k,$n

$n = len($s)-1

dim $t[$n],$l[$n],$c[255]

for $ = 0 to $n
$l[$] = asc(substr($s,$+1,1))
$j = $l[$]
$t[$] = $c[$j]
$c[$j] = $c[$j] + 1
next

for $ = 0 to 126
$k = $k + $c[$]
$c[$] = $k - $c[$]
next

for $ = 0 to $n
$x = $t[$x] + $c[$l[$x]]
$bwtdecode = chr($l[$x]) + $bwtdecode
next

endfunction

Again ... well done Howard and you too Patrick and m...

-Shawn

[ 29. December 2002, 22:22: Message edited by: Shawn ]

Top
#97332 - 2002-12-29 10:25 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
This was sorta where I came from...

Then eliminating some vars and putting some for/next inside each other gave me the previous Howard-a-like code...
_________________________
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...

Top
#97333 - 2002-12-29 10:28 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I think that it is rather interesting that ASC() successfully uses the LEFT most character of a multi-character string and does not error with an incorrect parameter error.

[ 30. December 2002, 19:27: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#97334 - 2002-12-29 10:36 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well, I think i may have found some kind of bug because this snippet:

code:
$j = $l[$]  
$t[$] = $c[$j]
$c[$j] = $c[$j] + 1

specifically these lines:

code:
$j = $l[$]  
$c[$j] = $c[$j] + 1

where $l[$] is temporarily assigned to $j. one can replace $j with the array ref like this:

code:
$c[$j] = $c[$l[$]] + 1

but this throws an exception:

code:
$c[$l[$]] = $c[$l[$]] + 1

which I think should be valid syntax. it would appear that nested arrays on the left side of an expression is not allowed ? Wouldn't have dented my score any but just wondering if this is an issue.

[ 29. December 2002, 22:39: Message edited by: Shawn ]

Top
#97335 - 2002-12-29 10:46 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Tell you one thing though ... its going to be quite a challenge to improve on Howards score there ... thats pretty tight code ...
Top
#97336 - 2002-12-29 10:48 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
I did it...
_________________________
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...

Top
#97337 - 2002-12-29 10:51 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
are you supposed to post it or keep it hidden ?
Top
#97338 - 2002-12-29 10:53 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
I enhanced his, see above after macieps code...

It's removing the ,1 in the first substr...
_________________________
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...

Top
#97339 - 2002-12-29 11:01 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You know Patrick, I think that the ability to drop the ",1" in the ASC(substr()) command string might be a bug. But in this case it is definitely working to your advantage. [Cool]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#97340 - 2002-12-29 11:04 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
[Big Grin] Agreed... [Big Grin]

Do we want to report the ASC and the array-in-array thingie to Ruud?

How to do this: mail him, post in beta, ???
_________________________
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...

Top
#97341 - 2002-12-29 11:16 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Definitely post in Beta ... Ruud checks that quite frequently.
Top
#97342 - 2002-12-29 11:45 PM Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Hi guys!

I'm back!

Thanks for starting to post the code. We didn't make it back in time, unfortunately, left to late in upstate New York.

Anyway, I've just read the posts of the first phase and I'm impressed. I wouldn't have thought that it could be done in under 200 keystrokes.

Also, to clarify this speed issue. As long as your code would have finished the longest one in time for the second phase to start it would have been fine, even if it would have taken 99 hours [Wink]

I also saw that some actually took time to read the original Burrows-Wheeler paper [Smile]

I like the idea of posting commented code as a third round, so that other might understand the code, too. I just took a quick look at the codes and I'll have to sit down tomorrow to actually start to understand what you code-wizards created.

Anyway, I signing out again and will be back tomorrow.

[ 29. December 2002, 23:46: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 3 123>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.131 seconds in which 0.085 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org