#97323 - 2002-12-29 08:57 PM
KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Howard Bullock
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
|
|
Top
|
|
|
|
#97326 - 2002-12-29 10:07 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
One of my previous versions was remarkably close to yours, Patrick.
|
|
Top
|
|
|
|
#97327 - 2002-12-29 10:12 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
maciep
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
|
|
|
|
#97329 - 2002-12-29 10:13 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Howard Bullock
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.
|
|
Top
|
|
|
|
#97331 - 2002-12-29 10:21 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Shawn
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
|
|
|
|
#97333 - 2002-12-29 10:28 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Howard Bullock
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 ]
|
|
Top
|
|
|
|
#97334 - 2002-12-29 10:36 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Shawn
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
|
|
|
|
#97339 - 2002-12-29 11:01 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Howard Bullock
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.
|
|
Top
|
|
|
|
#97342 - 2002-12-29 11:45 PM
Re: KiXGolf: Part 2: The Code: Burrows-Wheeler Transform
|
Sealeopard
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
I also saw that some actually took time to read the original Burrows-Wheeler paper
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
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 601 anonymous users online.
|
|
|