Sealeopard
(KiX Master)
2002-08-21 09:09 PM
KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Okay, Golf fanatics!

Time's up and you're allowed to post your code now. So take a look at the competitor and try to improve your code!

Lonkero: Must be torture for you to look at other people's code and not do anything about it [Wink]

Here's my code with a KiXtart Golf score of 702
code:
; beginning of the Anagram() UDF and supporting UDFs
;!
function anagram($)
dim $c, $d, $e, $b, $a, $i, $o, $f

if ubound($)<0
$f=''
else
$=s($)

$i=ubound($)

$f=$
for $c=0 to $i
$o=$[$c]
redim $l[25]
for $b=1 to len($o)
$a=asc(substr($o,$b,1))-97
$l[$a]=$l[$a]+1
next
$f[$c]=join($l)
next

for $c=0 to $i-1
for $d=$c+1 to $i
if $f[$c]=$f[$d] and $[$d]
$[$c]=$[$c]+' '+$[$d]
$[$d]=''
endif
next
next

$o=$
for $c=0 to $i
$d=split($[$c])
if ubound($d)
$o[$c]=right('0'+ubound($d),2)+$d[0]
endif
next

$o=s($o)

$f=$
$e=0
for $c=0 to $i
for $d=0 to $i
$b=substr($o[$c],3)
if $b=split($[$d],' ')[0] and $b
$f[$e]=$[$d]
$e=$e+1
endif
next
next
if $e
redim preserve $f[$e-1]
else
$f=''
endif

endif

$anagram=$f

endfunction
function s($)
dim $i,$j,$k,$m,$n
$k=ubound($)
for $i = 0 to $k
for $j = $i + 1 to $k
$m = $[$i]
$n = $[$j]
if $n < $m
$m = $n
$[$j] = $[$i]
$[$i] = $m
endif
next
next
$s = $
endfunction
;!
;!
; end of the Anagram() UDF and supporting UDFs



[ 21. August 2002, 21:11: Message edited by: sealeopard ]


**DONOTDELETE**
(Lurker)
2002-08-21 09:20 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Golf Score = 487
Uses Kixtart 4.10 + (Requires JOIN)
code:
FUNCTION anagram($J)
DIM $u, $,$a,$b,$c, $I,$O
$u = UBound($J)
$I = S($J) ; Sort the Input array
;
; Create anagram ID's for checking
FOR $ = 0 TO $u
DIM $t[20] ; Len($I[$])
FOR $a = 1 TO Len($I[$])
$t[$a] = Substr($I[$],$a,1)
NEXT
$J[$] = Join(S($t),'')
NEXT
;
; Get anagrams into a new array
;$O = '' $b = ''
FOR EACH $a IN $J ; for each anagram id
DIM $,$d
FOR $c = 0 TO $u
IF $a = $J[$c] AND $a ; If matches anagram id and word not null
$ = $ + ' ' + $I[$c] ; add word to line (already sorted)
$d = 1 + $d ; Increment word count
$J[$c] = 0 ; prevent it being selected again
ENDIF
NEXT
IF $d > 1 ; More than 1 word in anagram line
$O = $O +$b+ Chr($d)+$ ; Add <word count>+<line>
$b = # ; Char to split lines on
ENDIF
NEXT
;
$ = ''
IF $O
$ = S(Split($O,#)) ; Sort by Word count / Alpha
FOR $a = 0 TO Ubound($)
$[$a] = Substr($[$a],3) ; Remove words counter
NEXT
ENDIF
$anagram = $
ENDFUNCTION
;
;
FUNCTION S($) ;Sort routine
DIM $i,$t
FOR EACH $i IN $
FOR $i = 1 TO UBound($)
$t = $[$i-1]
IF $[$i] < $t
$[$i-1] =$[$i] $[$i] =$t
ENDIF
NEXT
NEXT
$S = $
ENDFUNCTION



LonkeroAdministrator
(KiX Master Guru)
2002-08-21 09:22 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

jens, sure.
but your code is so long and it does not use the bug in kix4.10
can't say it yet. with it you get something like 50 strokes out of your code...

anyway, waiting for other gurus to send their code.

{edit}
ajh has "longer" code too but he seemed to get it shorter. weird but seems that count of lines does not matter.

{edit 2}
I also tried to use another udf for something but it didn't save any length. that way got the same count!

{edit 3}
damn!
I found some strokes already in ajh's script.

[ 21. August 2002, 21:30: Message edited by: Lonkero ]


Howard Bullock
(KiX Supporter)
2002-08-21 09:26 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

KixGolf score = 625
code:
Function Anagram($)
Dim $a, $d, $i, $j, $k, $m, $n, $o, $t, $u, $x, $y, $w

$x = ubound($)
$u=$
gosub T
$y=0
for $i=0 to $x-1
if $[$i]
$w=0
$u[$w] = $[$i]
for $j=$i+1 to $x
if S($[$i])= S($[$j])
$w=$w+1
redim preserve $u[$w], preserve $k[$y], preserve $m[$y]
$u[$w] = $[$j]
$[$j] = 0
endif
next

if $w>0
$k[$y] = $w
$m[$y] = join($u," ")
$y=$y+1
endif
endif
next

$x=$y-1
$ = $k
$u = $m
gosub T

$Anagram =$u

:T
Do
$n=0
for $a=0 to $x-1

if $[$a]>$[$a+1]
$n=$[$a]
$o=$U[$a]

$[$a]=$[$a+1]
$U[$a]=$U[$a+1]

$[$a+1]=$n
$U[$a+1]=$o
endif
next
Until $n=0
return

Endfunction

Function S($)
Dim $b, $c, $i, $y
do
$y=1
for $i=1 to len($)-1
$b=substr($,$i,1)
$c=substr($,$i+1,1)
if $b > $c
$ = left($,$i-1) + $c + $b + substr($,$i+2)
$y=0
endif
next
until $y
$S=$
Endfunction



[ 21. August 2002, 21:28: Message edited by: Howard Bullock ]


MightyR1
(MM club member)
2002-08-21 11:50 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

What can I say?

W [Eek!] W
W [Eek!] W
W [Eek!] W

I'm going to try merging some code into mine....


LonkeroAdministrator
(KiX Master Guru)
2002-08-21 11:58 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

just don't make it shorter yet.

have some 3-4 places in AJH's script which should give one or two strokes. sadly can't test nor post them.

{edit}
have I ever told you that I'm not "good" loser.

[ 21. August 2002, 23:59: Message edited by: Lonkero ]


Sealeopard
(KiX Master)
2002-08-22 12:04 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Lonkero: What's the bug in 4.10 that you're talking about? The one that's supposed to save me 50 strokes?

LonkeroAdministrator
(KiX Master Guru)
2002-08-22 12:09 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

you will see when I post my code.
it's not actually bug in the code itself. just somewhere in the new stuff...

anyway, as I scroll trough all of your code, I gladly see that my code is somewhat fully different.

it's the only one which should work on all 4.xx (except 4.11 rc1)

{edit}
btw, jens did you see ruuds question on that beta topic?

[ 22. August 2002, 00:12: Message edited by: Lonkero ]


Sealeopard
(KiX Master)
2002-08-22 03:42 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Yeah, I saw his post. I don't think it's a critical thing that this type of syntax has been removed.

Personally, I can live without the SPLIT($a,',')[0] syntax but it'll definitely carry a penalty in future KiXtart Golf challanges.


LonkeroAdministrator
(KiX Master Guru)
2002-08-22 11:36 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

ok, my 495 code:
code:
function anagram($o)
dim $w,$c,$a,$l,$,$m,$b
for $=1 to ubound($o)
if $o[$]<$o[$-1]
$c=$o[$] $o[$]=$o[$-1] $o[$-1]=$c $=0
endif
next
for each $w in $o
$b=0
for each $ in $o
$c=$
for $l=1 to len($w)
$a=instr($,substr($w,$l,1))
$=left($,$a-1)+substr($,$a+1)
next
if 0=($|len($c)+1-$l)
$b="$b $c"
endif
next
if 1<ubound(split($b)) & 0=instr($m,$b)
$m="$m$b"
endif
next
$=split(substr($m,3),"0 ")
for $m=1 to ubound($)
if ubound(split($[$m]))<ubound(split($[$m-1]))
$o=$[$m] $[$m]=$[$m-1] $[$m-1]=$o $m=0
endif
next
if 0=len($[0]) $="" endif
$anagram=$
endfunction



LonkeroAdministrator
(KiX Master Guru)
2002-08-22 11:38 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

as a side note about that variety of the supported kix2001 versions.

it does not actually work with array in mind. it crawls the data as strings.


LonkeroAdministrator
(KiX Master Guru)
2002-08-23 12:24 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

HAHAA!
I said ajh has something to improve.
Golf Score: 484

code:
FUNCTION anagram($J)
DIM $u, $,$a,$b,$c, $I,$O
$u = UBound($J)
$I = S($J)

FOR $ = 0 TO $u
DIM $t[20]
FOR $a = 1 TO Len($I[$])
$t[$a] = Substr($I[$],$a,1)
NEXT
$J[$] = Join(S($t),'')
NEXT

FOR EACH $ IN $J
DIM $a,$d
FOR $c = 0 TO $u
IF $ = $J[$c] AND $
$a = '$a ' + $I[$c]
$d = 1 + $d
$J[$c] = 0
ENDIF
NEXT
IF $d > 1
$O = $O +$b+ Chr($d)+$a
$b = #
ENDIF
NEXT

$ = ''
IF $O
$ = S(Split($O,#))
FOR $a = 0 TO Ubound($)
$[$a] = Substr($[$a],3)
NEXT
ENDIF
$anagram = $
ENDFUNCTION

FUNCTION S($)
DIM $t
FOR EACH $s IN $
FOR $s = 1 TO UBound($)
$t = $[$s-1]
IF $[$s] < $t
$[$s-1] =$[$s] $[$s] =$t
ENDIF
NEXT
NEXT
$S = $
ENDFUNCTION



Richard H.Administrator
(KiX Supporter)
2002-08-22 01:26 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Hmm. Beats my 554 by quite a margin.
code:
Function Anagram($A)
Dim $B,$C,$I,$T,$E,$,$R,$Q,$X,$Y
$B=Ubound($A)
$A=S($A,$B)
For Each $C in $A
$X=0
$Y=""
If $C
For $E=0 To $B
$R=$A[$E]
If Len($R)=Len($C)
For $T=1 To Len($C)
$Q=InStr($R,SubStr($C,$T,1))
If $Q
$R=Left($R,$Q-1)+"."+SubStr($R,$Q+1)
Else
Goto M
EndIf
Next
$Y=$Y+" "+$A[$E]
$X=$X+1
$A[$E]=""
:M
EndIf
Next
If $X>1
$A[$]=""+$X+$Y
$=$+1
EndIf
EndIf
Next
If $
$=$-1
$A=S($A,$)
ReDim Preserve $A[$]
For $I=0 To $ $A[$I]=SubStr($A[$I],3) Next
Else
$A=""
EndIf
$Anagram=$A
EndFunction
Function S($A,$R)
Dim $T,$E,$
Do
$E=1
For $=1 to $R
If $A[$]<$A[$-1]
$T=$A[$]
$A[$]=$A[$-1]
$A[$-1]=$T
$E=0
EndIf
Next
Until $E
$S=$A
EndFunction



LonkeroAdministrator
(KiX Master Guru)
2002-08-22 01:30 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I tried the subfunction with the ubound and ubound split and made the comparing to be a matter of join split.
it did work but got the same score. well, ajh got that subfunction to work.

anyway, jens, the thing I ment about the bug was the:
$rc=SETOPTION('NoVarsInString','ON')

I surely used vars in strings in my udf.

cheers.


Fernando Madruga
(Starting to like KiXtart)
2002-08-22 07:45 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

So, what is the lowest score so far?

I'm new to KiXtart and have been fighting it most of the afternoon. Yes, fighting is the word... Either script error reporting on this thing is RUDE or I'm missing something... I have this cool idea for a bombastic implementation of the current Golf Tournament, but I've been fighting the damn KiX trying to do something that I should be able to do in 30 minutes on a decent language... [Frown]

One such example: I've spent LOADS of time trying to get a function to return something and kept getting a criptic error message! All because I forgot the $ before the function name to return the value! After all, I thought the $ was for variables and the documentation for the Function/EndFunction does IMPLY that it's not used! Sure, the example DOES use it, but I was coding my func from scratch and I took some time to figure that out.

I must say, that in over 20 years of programming in 10s of languages, from several makes of assembler to SmallTalk and many more in between, this one is surely the worst I've seen in syntax error reporting!

As of now, I'm fighting to get the function call to work TWICE!

Almost a nightmare!

Anyway, just felt to take a break and find out what is the current low score to beat!

Bye,
Fernando Madruga

P.S.: Is the "Preview Post" button working? Can't get to preview my posts either... [Frown]


LonkeroAdministrator
(KiX Master Guru)
2002-08-22 07:52 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

fernando, I quess it's the 484.

what comes to the error reporting, sure, syntax error is syntax error and it's always the same.

anyway, if you use kixstrip (from kixtart.org main page click the scripts link. there is packet for it) which checks for syntax errors and nicely says them.

also it collects at the end the summary in nice format.

for proper error getting, I think we should have a editor to check for the syntax errors.

as you might have tried c++, you are unable to even run your code before you have correct syntax in it.

this should help "dummyes" a lot and save a lot of time and I think one is coming up shortly.


**DONOTDELETE**
(Lurker)
2002-08-22 07:55 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I'm sorry Lonkero, but I think you missed it.
I backed out your changes to the central loop as it was the same
length as mine, but used ('$a ') which I don't think is allowed.
You reduced the Sort UDF by 3 but missed your own trick,
namely setting the loop var to zero on a swap,
allowing me to remove the outer loop.
Golf score = 472
code:
FUNCTION anagram($J)
DIM $u, $,$a,$b,$c, $I,$O
$u = UBound($J)
$I = S($J)

FOR $ = 0 TO $u
DIM $t[20]
FOR $a = 1 TO Len($I[$])
$t[$a] = Substr($I[$],$a,1)
NEXT
$J[$] = Join(S($t),'')
NEXT

FOR EACH $a IN $J
DIM $,$d
FOR $c = 0 TO $u
IF $a = $J[$c] AND $a
$ = $ + ' ' + $I[$c]
$d = 1 + $d
$J[$c] = 0
ENDIF
NEXT
IF $d > 1
$O = $O +$b+ Chr($d)+$
$b = #
ENDIF
NEXT

$ = ''
IF $O
$ = S(Split($O,#))
FOR $a = 0 TO Ubound($)
$[$a] = Substr($[$a],3)
NEXT
ENDIF
$anagram = $
ENDFUNCTION
;
FUNCTION S($)
DIM $t
FOR $S = 1 TO UBound($)
$t = $[$S-1]
IF $[$S] < $t
$[$S-1] =$[$S] $[$S] =$t
$S = 0
ENDIF
NEXT
$S = $
ENDFUNCTION



Fernando Madruga
(Starting to like KiXtart)
2002-08-22 08:01 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

That high?! Cool! I was expecting it to be below 400 by now!

Thanks for the kixstrip tip. I'll try it now and find out.

Later,
Fernando Madruga


LonkeroAdministrator
(KiX Master Guru)
2002-08-22 08:01 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

it is allowed as rules do not disallow it.

if the novarsinstrings would work, then it wouldn't be even possible.

anyway, I like good challenge and surely you are giving me one!

to your knowledge, I remembered to take my laptop home tonight, so I'll be back once I've seen couple of movies and drinked some sweet liquid...


Sealeopard
(KiX Master)
2002-08-22 08:02 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Fernando:

There are trade-offs for a light-weight scripting language. Remember that the 16-bit version had to fit within the DOS memory. Also, KiXtart is a free-format language and does not impose restrictions like C++ with those damn ';' that I alwasy forget.

Also, most of use start with a regular script with normal variable names before starting to reduce variable names. That makes it easier to debug it. You can also use DEBUG ON in the first line of your script to run it in debug mode.


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 01:06 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Well, I give up... Any way I turn, I bump into some wall... I've thought of half a dozen algorithms (one was even very similar to some here posted, but that I wanted to implement in some more creative ways, which, of course, can't be done due to KiXtart's limitations... [Frown] )

So, I give up.

I can however mention that AJH's code can be shrunk to 467 and still work: just remove the lonelly AND $a and it does the trick...

Later,
Fernando Madruga

[ 23. August 2002, 01:07: Message edited by: Fernando Madruga ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-23 01:39 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

fernando, have you tried that?

I have and it does not work!

ok, you might be a programmer but we have all been playing with this code about 72 hours.

it's at the minimum it can get.

and if you want to make yourself, just contribute.

also, about the lacks of the kixtart, you can post them to suggestions or to starters or directly to us or ruud.

there are allways someone wanting something to be done better and if it really is better, it will be done.

just suggest. ruud is really flexible as he does not live in america or middle east... [Wink]

[ 23. August 2002, 01:43: Message edited by: Lonkero ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-23 01:52 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

ajh, sorry.
I' doing this just to tease you.
as winner of last golf I have to keep up the fight.
sadly brianTX isn't here as he would have been fighting it to 450.

anyway, 471 is current score with simple change as:
code:
FUNCTION anagram($J)
DIM $u, $,$a,$b,$c, $I,$O
$u = UBound($J)
$I = S($J)

FOR $ = 0 TO $u
DIM $t[20]
FOR $a = 1 TO Len($I[$])
$t[$a] = Substr($I[$],$a,1)
NEXT
$J[$] = Join(S($t),'')
NEXT

FOR EACH $a IN $J
DIM $c,$d
FOR $ = 0 TO $u
IF $a = $J[$] and $a
$c = '$c ' + $I[$]
$d = 1 + $d
$J[$] = 0
ENDIF
NEXT
IF $d > 1
$O = $O +$b+ Chr($d)+$c
$b = #
ENDIF
NEXT

$ = ''
IF $O
$ = S(Split($O,#))
FOR $a = 0 TO Ubound($)
$[$a] = Substr($[$a],3)
NEXT
ENDIF
$anagram = $
ENDFUNCTION
;
FUNCTION S($)
DIM $t
FOR $S = 1 TO UBound($)
$t = $[$S-1]
IF $[$S] < $t
$[$S-1] =$[$S] $[$S] =$t
$S = 0
ENDIF
NEXT
$S = $
ENDFUNCTION

BTW, thanks for giving me a lesson.
we all need to learn if we want to really understand something.
I quess you are to reduce the score, but I'll rest knowing I learned something today.
thanks.

[ 23. August 2002, 01:54: Message edited by: Lonkero ]


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 02:09 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I did try that and it DOES work.
I'll check if I'm using the latest KiXGolf3...

BTW: I'm running 4.11 RC 1...

Later,
Fernando Madruga


LonkeroAdministrator
(KiX Master Guru)
2002-08-23 02:14 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

thanks to greatest newbie I've ever seen.
I can defend myself by saying it wasn't my code but borroed.
anyway, thank you fernando.
466 is my score
code:
FUNCTION anagram($J)
DIM $u, $,$a,$b,$c, $I,$O
$u = UBound($J)
$I = S($J)

FOR $ = 0 TO $u
DIM $t[20]
FOR $a = 1 TO Len($I[$])
$t[$a] = Substr($I[$],$a,1)
NEXT
$J[$] = Join(S($t),'')
NEXT

FOR EACH $a IN $J
DIM $c,$d
FOR $ = 0 TO $u
IF $a = $J[$]
$c = '$c ' + $I[$]
$d = 1 + $d
$J[$] = 0
ENDIF
NEXT
IF $d > 1
$O = $O +$b+ Chr($d)+$c
$b = #
ENDIF
NEXT

$ = ''
IF $O
$ = S(Split($O,#))
FOR $a = 0 TO Ubound($)
$[$a] = Substr($[$a],3)
NEXT
ENDIF
$anagram = $
ENDFUNCTION
;
FUNCTION S($)
DIM $t
FOR $S = 1 TO UBound($)
$t = $[$S-1]
IF $[$S] < $t
$[$S-1] =$[$S] $[$S] =$t
$S = 0
ENDIF
NEXT
$S = $
ENDFUNCTION

{edit}
fernando, why you did not post it?

it would have been nice shock to get a leading score from someone we don't know.

you know, I tried it "without" the and, meaning I tried it with and symbol "&"...

stupid me again...

[ 23. August 2002, 02:16: Message edited by: Lonkero ]


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 02:38 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

463
code:
Function anagram($J)
Dim $u,$,$a,$b,$I,$O
$u = Ubound($J)
$I = S($J)

For $ = 0 TO $u
Dim $t[20]
For $a = 1 TO Len($I[$])
$t[$a] = SubStr($I[$],$a,1)
Next
$J[$] = Join(S($t),'')
Next

For Each $a IN $J
Dim $c,$d
For $ = 0 TO $u
If $a = $J[$]
$c = '$c ' + $I[$]
$d = 1 + $d
$J[$] = 0
EndIf
Next
If $d > 1
$O = $O +$b+ Chr($d)+$c
$b = #
EndIf
Next

$ = ''
If $O
$ = S(Split($O,#))
For $a = 0 TO Ubound($)
$[$a] = SubStr($[$a],3)
Next
EndIf
$anagram = $
EndFunction
;
Function S($)
Dim $t
For $S = 1 TO Ubound($)
$t = $[$S-1]
If $[$S] < $t
$[$S-1] =$[$S] $[$S] =$t
$S = 0
EndIf
Next
$S = $
EndFunction



LonkeroAdministrator
(KiX Master Guru)
2002-08-23 02:40 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

fernando, now we are talking.
thanks for this.

you will be hearing from us [Big Grin]


Sealeopard
(KiX Master)
2002-08-23 02:55 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I just ran Fernando's code through the latest test suite and it doesn't pass the second test with a script error. Can anybody confirm this?

disregard this, I messed up different KiXtart versions.

[ 23. August 2002, 15:54: Message edited by: sealeopard ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-23 02:59 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

with 4.11 beta 2 it says success. also with beta 1 and 4.10

Fernando Madruga
(Starting to like KiXtart)
2002-08-23 03:02 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Now that it's clear, I'll delete this long msg...
The hint does stay however!
Add some version info to the test suite!

Later,
Madruga

[ 23. August 2002, 03:11: Message edited by: Fernando Madruga ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-23 03:05 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

the shell command never worked for me either.

I think they should decide do they call it from commandline or what...

anyway, I see no problems with your script, so until there is solid prove it is not working, I'll think and believe it's the leader.


Sealeopard
(KiX Master)
2002-08-23 03:07 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Yes, I just rechecked everythink. It looked like I used an incorrect version of Kixtart. I now rechecked everything with KiXtart 4.11 RC1 and it all looks fine. Sorry for jumping the gun.

[ 23. August 2002, 15:55: Message edited by: sealeopard ]


Sealeopard
(KiX Master)
2002-08-23 03:15 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

And now that I meessed it up...

I improved Fernando's script down to 460!
code:
Function anagram($J)
Dim $u,$,$a,$b,$I,$O
$u = Ubound($J)
$I = S($J)

For $ = 0 TO $u
Dim $t[20]
For $a = 1 TO Len($I[$])
$t[$a] = SubStr($I[$],$a,1)
Next
$J[$] = Join(S($t))
Next

For Each $a IN $J
Dim $c,$d
For $ = 0 TO $u
If $a = $J[$]
$c = '$c ' + $I[$]
$d = 1 + $d
$J[$] = 0
EndIf
Next
If $d > 1
$O = $O +$b+ Chr($d)+$c
$b = #
EndIf
Next

$ = ''
If $O
$ = S(Split($O,#))
For $a = 0 TO Ubound($)
$[$a] = SubStr($[$a],3)
Next
EndIf

$anagram = $
EndFunction
;
Function S($)
Dim $t
For $S = 1 TO Ubound($)
$t = $[$S-1]
If $[$S] < $t
$[$S-1] =$[$S] $[$S] =$t
$S = 0
EndIf
Next
$S = $
EndFunction

by modifying the JOIN function.

[ 23. August 2002, 03:23: Message edited by: sealeopard ]


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 03:19 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Surely you meant 460? [Big Grin]

That's where my lack of experience with KiXtart kicks in, or I would surely not miss that one... [Smile]

Later,
Madruga


Sealeopard
(KiX Master)
2002-08-23 03:23 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Yeah, 460, I guess it's enough computer screens for me now.

LonkeroAdministrator
(KiX Master Guru)
2002-08-23 03:53 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

well, as my laptops battery is dying, I'll get to bed.

anyway, as a quick quess, I could try making it to the 455.

we will see tomorrow.


MightyR1
(MM club member)
2002-08-23 09:15 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

457 :

code:
Function anagram($J)
Dim $u,$,$a,$b,$I,$O
$u = Ubound($J)
$I = S($J)

For $ = 0 TO $u
Dim $t[20]
For $a = 1 TO Len($I[$])
$t[$a] = SubStr($I[$],$a,1)
Next
$J[$] = Join(S($t))
Next

For Each $a IN $J
Dim $c,$d
For $ = 0 TO $u
If $a = $J[$]
$c = '$c ' + $I[$]
$d = 1 + $d
$J[$] = 0
EndIf
Next
If $d > 1
;--> $O = $O +$b+ Chr($d)+$c
$O = $O +$b+ '$d'+$c
$b = #
EndIf
Next

$ = ''
If $O
$ = S(Split($O,#))
For $a = 0 TO Ubound($)
$[$a] = SubStr($[$a],3)
Next
EndIf

$anagram = $
EndFunction
;
Function S($)
Dim $t
For $S = 1 TO Ubound($)
$t = $[$S-1]
If $[$S] < $t
$[$S-1] =$[$S] $[$S] =$t
$S = 0
EndIf
Next
$S = $
EndFunction



Fernando Madruga
(Starting to like KiXtart)
2002-08-23 10:33 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

So, you guys want to play hard, eh?

How about 454??!

code:
Function anagram($J)
Dim $u,$,$a,$b,$I,$O
$u = Ubound($J)
$I = S($J)

For $ = 0 TO $u
Dim $t[20]
For $a = 1 TO Len($I[$])
$t[$a] = SubStr($I[$],$a,1)
Next
$J[$] = Join(S($t))
Next

For Each $a IN $J
Dim $c,$d
For $ = 0 TO $u
If $a = $J[$]
$c = '$c ' + $I[$]
$d = 1 + $d
$J[$] = 0
EndIf
Next
If $d > 1
$O = "$O$b$d$c"
$b = #
EndIf
Next

$ = ''
If $O
$ = S(Split($O,#))
For $a = 0 TO Ubound($)
$[$a] = SubStr($[$a],3)
Next
EndIf

$anagram = $
EndFunction
;
Function S($)
Dim $t
For $S = 1 TO Ubound($)
$t = $[$S-1]
If $[$S] < $t
$[$S-1] =$[$S] $[$S] =$t
$S = 0
EndIf
Next
$S = $
EndFunction

Next...

[ 23. August 2002, 10:38: Message edited by: Fernando Madruga ]


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 03:03 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

And how about 441 ???

code:
feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
UDF passed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test
The Anagram() UDF passed validation
kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf score = 441

This one will probably not count [Frown] as this score is taking into account a bug that I found looking at the KiXGolf3.kix !!!

Here's the code, anyway:
code:
Function anagram($J)
Dim $u,$,$,$b,$I,$O
$u = Ubound($J)
$I = S($J)

For $ = 0 TO $u
Dim $t[20]
For $ = 1 TO Len($I[$])
$t[$] = SubStr($I[$],$,1)
Next
$J[$] = Join(S($t))
Next

For Each $ IN $J
Dim $c,$d
For $ = 0 TO $u
If $ = $J[$]
$c = '$c ' + $I[$]
$d = 1 + $d
$J[$] = 0
EndIf
Next
If $d > 1
$O = "$O$b$d$c"
$b = #
EndIf
Next

$ = ''
If $O
$ = S(Split($O,#))
For $ = 0 TO Ubound($)
$[$] = SubStr($[$],3)
Next
EndIf

$anagram = $
EndFunction
;
Function S($)
Dim $
For $S = 1 TO Ubound($)
$ = $[$S-1]
If $[$S] < $
$[$S-1] =$[$S] $[$S] =$
$S = 0
EndIf
Next
$S = $
EndFunction

What's the bug?
code:
 
(Had to place inside code tags so I could use < and <=)

Well, KiXGolf does not include the 127th ASCII character (a < where a <= should
be used!) on it's count for valid characters, so I made the following changes to
the previously posted code:

- In function S (and only there!) I replace all $t with $
- In function Anagram, replaced all $a with $ (I used $a 'cause it's the one
that is used more times!)
- Finally, I replaced $nagram back to the correct $anagram (that one got
caught in the above replace!)

Have fun,
Madruga

[ 23. August 2002, 15:20: Message edited by: Fernando Madruga ]


Sealeopard
(KiX Master)
2002-08-23 04:08 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Hmm, very creative. Unfortunately, this takes advantage of a bug in the counting script, however, you still do have key-strokes, thus they do count (actually, each ALT+127 character would probably count as four keystrokes, one for the ALT, and one each for the digits).

And, according to the rules, all keystrokes count, with the exeption of whitespace and everything that is not needed for a functioning script like charriage returns, line feeds, extra spaces, comments.

[ 23. August 2002, 16:24: Message edited by: sealeopard ]


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 04:17 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

That's what I thought! [Smile]

Hint If you're going to fix KixGolf3, you could take the time to add a comment to the very top of it with a version number, so we can know just by looking at that line if we have the most recent version...

Also, Alt-127 can't count as 4 strokes because then $ (among others) would have to count as 2!

Later,
Madruga


Sealeopard
(KiX Master)
2002-08-23 04:51 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Actually, if you want to be really precise, then the KiXtart Golf score is the number of bytes in a non-UNICODE text file that only contains the appropriate UDF and that is still runnable through KiXtart.
For example
code:
function anagram($) dim $a for $a=1 to 10 next $anagram=0 endfunction

is a valid KiXtart script and the filesize equals the KiXtart Golf score. Note that there are no CR/LFs and/or excess spaces...


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 05:20 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Sorry for disagreeing, but that's not true: the filezise would be 69 characters, and the kixgolf3 score is just 59 as it does not count spaces unless they're inside a string and there are 10 in there. (And yes, I did try it! (changed KixGolf3 to start counting at once, instead of waiting for the ;! tag)

Later,
Madruga

P.S.: But I did get the point though! [Big Grin]


Howard Bullock
(KiX Supporter)
2002-08-23 06:59 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I wrote the KixGolf code and we have had this discussion previously about the spaces that would be required for example in "For Each $a IN $array" but I do not have the desire to code every command syntax that includes spaces as part of the syntax. the program as is provides an easy method to score a program giving a consistent measurement for which to compare scripts.

As for not including Asc(127), that was by design because I saw no reason anyone would include it as part of normal coding for these sessions of Fun and comradery.

[ 23. August 2002, 19:00: Message edited by: Howard Bullock ]


Howard Bullock
(KiX Supporter)
2002-08-23 07:04 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

If anyone wants to improve upon the KixGolf scoring script feel free. I think that using regular expressions would be the easiest way to locate commands that require spaces, count them and them adjust the score accordingly. (See my last Kix Golf tournament code for how to use RegEx.)

[ 23. August 2002, 19:08: Message edited by: Howard Bullock ]


Sealeopard
(KiX Master)
2002-08-23 07:05 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Howard:

I would just keep the kixgolf3.kix as is. Then the kixgolf3.kix will be used exclusively as the scoring script for all future KiXtart Golf events.

I will thus explicitly state that using characters above ASCII 126 or other ASCII characters that take advantage fo the particular way the scoring script works will not be allowed and will result in the disqualification of both the code and the coder.

In general, taking advantage of shortcomings in the scoring script will not be allowed.


Fernando Madruga
(Starting to like KiXtart)
2002-08-23 07:30 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Ok.

So I felt free to "improve/fix" KixGolf3 and here's the updated version, featuring only 2 changes:
- Added a line with a version info and latest coder to "fix/change" something, plus a change history.
- Fixed the 127 char (as I can see no reason why not to fix it.

Later,
Madruga

code:
; KixGolf.kix  (Version 3)
;
; V 3.0.1 (2002/08/23@18:30) - Fernando Madruga
; Fixed handling of CHR(127) and added version info
;
; This function scores the specified file and returns
; the KixGolf score. That is the total number of key strokes
; used to build a script not counting comments, spaces, tabs,
; or any ASCII character above 126.
;
; The script will start counting on "odd" (1,3,5,...) occurrences
; of ";!" and the script will stop counting after "even" (0,2,4,...)
; instances of ";!". Note that ";!" must be placed starting in column
; number 1.
;
;A debug mode has been added in this version. The debug mode
;is controlled with the use of ";~" at the beginning of the line like
; the count controller (;!) above. You start and stop debugging
;as many time as you like while counting is enabled.
;
;Debug data is written to a file in the same directory that this
;program resides. The file name is that of the target file name with
;".debug" as an extension. Data will only be written while counting is
;active.
;
;The data written if the character being analyzed, it's ASCII decimal
;value, if it was counted or not, and a running total.
;
;Syntax: %tmp%\kix32 kixgolf.kix $F=Kixgolf.kix
;


; $F must be initialized on the command line.
; Syntax: kix32 kixgolf.kix $F=test.kix
?
? "KixGolf score = " + KixGolf($F)
?

;!
Function KixGolf($F)
$debugfile=@ScriptDir+"\"+$F+".debug"
Del $debugfile
$Line=0
$Y=0 $D=0 $S=0
if open (1,$F) = 0
Do
if $L
$Line = $Line + 1
$ZZ = (left($L,2)=";~")
$debug = $debug + $ZZ & 1
if $debug & $olddebug<>$debug
WriteLog2($debugfile,"Debug Started at Line: " + $Line,1)
WriteLog2($debugfile,"--------------------------------------------------")
$olddebug=$debug
endif
if not $debug & $olddebug<>$debug
WriteLog2($debugfile,"--------------------------------------------------")
WriteLog2($debugfile,"Debug Stopped at Line: " + $Line,1)
$olddebug=$debug
endif
$Z = (left($L,2)=";!")
$Y = $Y + $Z & 1
if not $Z & not $ZZ
$x=len($L)
for $h=1 to $x
$A=asc(substr($L,$h,1))-32
$D = $D + ($A=2) & 1 & not $S
$S = $S + ($A=7) & 1 & not $D
if $debug
$Q = $D | $S
if $Q<>$oldQ
if $Q
WriteLog2($debugfile,"Quotes ON at: " + chr($A+32))
else
WriteLog2($debugfile,"Quotes OFF at: " + chr($A+32))
endif
endif
$oldQ=$Q
endif
if not $D & not $S & ($A=27)
$h=$x+1
if $debug
WriteLog2($debugfile,chr($A+32) + " " + ($A+32) + " Count=0 ")
$text="Comment found. Ignore to EOL. Next character should be" +
" 1st char of new line."
WriteLog2($debugfile,$text)
endif
else
$=$+($Y & (($A>0 & $A<96) | $D | $S))
if $debug
$text=chr($A+32) + " " + ($A+32) + " Count=" +
($Y & (($A>0 & $A<96) | $D | $S)) + " " + $
WriteLog2($debugfile,$text)
endif
endif
next
endif
endif
$L=ReadLine(1)
Until @error
else
"Bad File Name: $F" ?
$="NA"
endif
if $D | $S
? "Mis-matched quotes. Probable score error." ?
endif
if $olddebug
? "Debug File: " +$debugfile ?
endif
$KixGolf=$
EndFunction

;--------------------------------------------------------------------------------------------------
;FUNCTION WriteLog2()
;
;AUTHOR Howard A. Bullock (hbullock@tycoelectronics.com)
;
;ACTION Generic logging facility for scripts. Appends log entry to a file with an
; optional TimeStamp.
;
;SYNTAX WriteLog2($File, $text, [0|1])
;
;PARAMETERS $File (Required) - String value
; $text (Required) - String value
; $TimeStamp (Optional) Default(0) no TimeStamp (1 or 0)
;
;
;REMARKS This function writes (appends) an optionally time stamped log entry to the file
; defined in function. This function searches for the first unused file handle,
; open the file, and write the entry. The file handle is then closed. When the
; function is unable to perform its it write the error is displayed in a message box.
;
;RETURNS Nothing
;
;DEPENDENCIES None
;
;EXAMPLES WriteLog2("junk.txt","This is a test")
; WriteLog2("junk.txt","This is a test",0)
; WriteLog2("junk.txt","This is a test",1)
;
;
Function WriteLog2($File, $Text, optional $TimeStamp)
dim $RC, $File, $text, $FH, $TimeStamp
$FH=1
$RC=Open ($FH, $File, 5)
while $RC = -3
$FH=$FH +1
$RC=Open ($FH, $File, 5)
Loop
Select
Case $RC=0
if ($TimeStamp=1)
$TimeStamp = @Date + " " + @Time + " - "
else
$TimeStamp = ""
endif
$RC=Writeline ($FH, $TimeStamp + $Text + @CRLF)
$RC=Close ($FH)
Case $RC=-2
$text = "WriteLog2: Invalid file handle ($FH) specified when trying to Open $File."
$RC=MessageBox ($text,"Script Error",48)
Case $RC=-1
$text = "WriteLog2: Invalid file name ($File) specified for log file."
$RC=MessageBox ($text,"Script Error",48)
Case $RC=>0
$text = "System Error($RC) while attempting to open log file ($File)."
$RC=MessageBox ($text,"Script Error",48)
Endselect
EndFunction
;--------------------------------------------------------------------------------------------------



Fernando Madruga
(Starting to like KiXtart)
2002-08-23 07:42 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Eheh... Here's 3.0.2 [Smile]

It's nicer (and useful) to have the version info printed alongside the score, so one does not have to look into the script...

Later,
Fernando Madruga

code:
; KixGolf.kix  (Version 3)
;
$Version = "3.0.2" ; (2002/08/23@18:45) - Fernando Madruga
; Now prints the version code with the score
;
; V 3.0.1 (2002/08/23@18:30) - Fernando Madruga
; Fixed handling of CHR(127) and added version info
;
; This function scores the specified file and returns
; the KixGolf score. That is the total number of key strokes
; used to build a script not counting comments, spaces, tabs,
; or any ASCII character above 126.
;
; The script will start counting on "odd" (1,3,5,...) occurrences
; of ";!" and the script will stop counting after "even" (0,2,4,...)
; instances of ";!". Note that ";!" must be placed starting in column
; number 1.
;
;A debug mode has been added in this version. The debug mode
;is controlled with the use of ";~" at the beginning of the line like
; the count controller (;!) above. You start and stop debugging
;as many time as you like while counting is enabled.
;
;Debug data is written to a file in the same directory that this
;program resides. The file name is that of the target file name with
;".debug" as an extension. Data will only be written while counting is
;active.
;
;The data written if the character being analyzed, it's ASCII decimal
;value, if it was counted or not, and a running total.
;
;Syntax: %tmp%\kix32 kixgolf.kix $F=Kixgolf.kix
;


; $F must be initialized on the command line.
; Syntax: kix32 kixgolf.kix $F=test.kix
?
? "KixGolf v" + $Version + " score = " + KixGolf($F)
?

;!
Function KixGolf($F)
$debugfile=@ScriptDir+"\"+$F+".debug"
Del $debugfile
$Line=0
$Y=0 $D=0 $S=0
if open (1,$F) = 0
Do
if $L
$Line = $Line + 1
$ZZ = (left($L,2)=";~")
$debug = $debug + $ZZ & 1
if $debug & $olddebug<>$debug
WriteLog2($debugfile,"Debug Started at Line: " + $Line,1)
WriteLog2($debugfile,"--------------------------------------------------")
$olddebug=$debug
endif
if not $debug & $olddebug<>$debug
WriteLog2($debugfile,"--------------------------------------------------")
WriteLog2($debugfile,"Debug Stopped at Line: " + $Line,1)
$olddebug=$debug
endif
$Z = (left($L,2)=";!")
$Y = $Y + $Z & 1
if not $Z & not $ZZ
$x=len($L)
for $h=1 to $x
$A=asc(substr($L,$h,1))-32
$D = $D + ($A=2) & 1 & not $S
$S = $S + ($A=7) & 1 & not $D
if $debug
$Q = $D | $S
if $Q<>$oldQ
if $Q
WriteLog2($debugfile,"Quotes ON at: " + chr($A+32))
else
WriteLog2($debugfile,"Quotes OFF at: " + chr($A+32))
endif
endif
$oldQ=$Q
endif
if not $D & not $S & ($A=27)
$h=$x+1
if $debug
WriteLog2($debugfile,chr($A+32) + " " + ($A+32) + " Count=0 ")
$text="Comment found. Ignore to EOL. Next character should be" +
" 1st char of new line."
WriteLog2($debugfile,$text)
endif
else
$=$+($Y & (($A>0 & $A<96) | $D | $S))
if $debug
$text=chr($A+32) + " " + ($A+32) + " Count=" +
($Y & (($A>0 & $A<96) | $D | $S)) + " " + $
WriteLog2($debugfile,$text)
endif
endif
next
endif
endif
$L=ReadLine(1)
Until @error
else
"Bad File Name: $F" ?
$="NA"
endif
if $D | $S
? "Mis-matched quotes. Probable score error." ?
endif
if $olddebug
? "Debug File: " +$debugfile ?
endif
$KixGolf=$
EndFunction

;--------------------------------------------------------------------------------------------------
;FUNCTION WriteLog2()
;
;AUTHOR Howard A. Bullock (hbullock@tycoelectronics.com)
;
;ACTION Generic logging facility for scripts. Appends log entry to a file with an
; optional TimeStamp.
;
;SYNTAX WriteLog2($File, $text, [0|1])
;
;PARAMETERS $File (Required) - String value
; $text (Required) - String value
; $TimeStamp (Optional) Default(0) no TimeStamp (1 or 0)
;
;
;REMARKS This function writes (appends) an optionally time stamped log entry to the file
; defined in function. This function searches for the first unused file handle,
; open the file, and write the entry. The file handle is then closed. When the
; function is unable to perform its it write the error is displayed in a message box.
;
;RETURNS Nothing
;
;DEPENDENCIES None
;
;EXAMPLES WriteLog2("junk.txt","This is a test")
; WriteLog2("junk.txt","This is a test",0)
; WriteLog2("junk.txt","This is a test",1)
;
;
Function WriteLog2($File, $Text, optional $TimeStamp)
dim $RC, $File, $text, $FH, $TimeStamp
$FH=1
$RC=Open ($FH, $File, 5)
while $RC = -3
$FH=$FH +1
$RC=Open ($FH, $File, 5)
Loop
Select
Case $RC=0
if ($TimeStamp=1)
$TimeStamp = @Date + " " + @Time + " - "
else
$TimeStamp = ""
endif
$RC=Writeline ($FH, $TimeStamp + $Text + @CRLF)
$RC=Close ($FH)
Case $RC=-2
$text = "WriteLog2: Invalid file handle ($FH) specified when trying to Open $File."
$RC=MessageBox ($text,"Script Error",48)
Case $RC=-1
$text = "WriteLog2: Invalid file name ($File) specified for log file."
$RC=MessageBox ($text,"Script Error",48)
Case $RC=>0
$text = "System Error($RC) while attempting to open log file ($File)."
$RC=MessageBox ($text,"Script Error",48)
Endselect
EndFunction
;--------------------------------------------------------------------------------------------------



[ 23. August 2002, 19:43: Message edited by: Fernando Madruga ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-23 10:15 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

so, seems that you already gave up the shortening as you started to play with the counter...

Fernando Madruga
(Starting to like KiXtart)
2002-08-23 11:21 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Well, I don't think that I know KiXtart enough to go beyong this... [Smile] Maybe there are some fat bytes around, but it probably won't be me the one who trims them down... [Smile]

As for the counter, I felt curious at one time and had a look at it; found a bug; reported; fixed; all done... [Big Grin]

Right now I'm into analysing sealeopard's code in KSMS so that I have a better understanding of what/how to change/propose changes for.

One particular situation that I'm studying is a way to make inventory reports work quickly, even on some of the branches that are linked only by a 32/64 kbps Frame-Relay link. Using an access DB is most likely out of the question (too slow over a slow link), as will probably be using SQL server (needs client DB drivers), so I'll probably stick with an HTTP server (maybe something I'll hack quickly in perl) that will receive url requests that are in fact posting info, like http:81//myserver/inventory/pc_name="foobar"&processor="PIII@1100MHz"& etc, etc, etc and will then update a local DB with any postings received...

I'll let the group know when I'm done with that. I'm considering implementing KSMS sometime next week...

As for the Golf Contest, well, I'll keep checking the results to see if someone drops below 454... [Smile]

Later,
Madruga

[ 23. August 2002, 23:23: Message edited by: Fernando Madruga ]


Howard Bullock
(KiX Supporter)
2002-08-24 02:26 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Fernando, I thought I recognized your name. Now that you mentioned Perl, I remember you from the Perl-Win32-Users@listserv.ActiveState.com. [Cool]

Fernando Madruga
(Starting to like KiXtart)
2002-08-24 02:47 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

(Out-of-topic)

Yep.

That's me! Allways striving to find the best tool/language for the job. Even though I came to love perl, KiXtart may be the tool for this one, so I'll probably end up here for a while... [Big Grin]

Later,
Madruga


LonkeroAdministrator
(KiX Master Guru)
2002-08-24 03:03 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I have always had somekind of hate relationship with perl.

and still, I prefer tcl.


**DONOTDELETE**
(Lurker)
2002-08-25 12:22 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I must be seriously missing something because the last version of the
script that passes test 2 (the empty array) is the 471 code.
I am running Kix 4.10 build 99.
Starting with the 466 code all scripts report:
'The output array has an incorrect size of 9'

Also the 457 code changes will work provided the number of anagrams
is less than 10 (due to the SubStr($[$a],3) lower down)


LonkeroAdministrator
(KiX Master Guru)
2002-08-24 01:42 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I made my script with 4.11 beta2

-


Fernando Madruga
(Starting to like KiXtart)
2002-08-24 02:06 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

You're {edit} half {/edit} right...

1st, the code DOES work in 4.11 RC 1 (the one I'm using) (wait a sec...) Just cheking under 4.10 and yes, it does work here!

code:
[d:\work\admin\kixtart\kix 2001 - 4.10]KIX32.EXE anagram_test.kix

feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
UDF passed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test
The Anagram() UDF passed validation
kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf v3.0.2 score = 454

I'd sugest copying the latest KixGolf (3.0.2) {edit} 3.0.3 {/edit} and using that instead.

As for not working with more than 10 anagrams, that is not true. I tried with these input:
code:
$inputarray='a1,1a,a2,2a,a3,3a,a4,4a,a5,5a,a6,6a,a7,7a,a8,8a,a9,9a,hack,snooped,tables,
salt,spiff,feeling,spooned,last,grep,bleats,gas,ablest,fleeing,stable,slat,drive'

$correctoutput='1a a1,2a a2,3a a3,4a a4,5a a5,6a a6,7a a7,8a a8,9a a9,feeling fleeing,
snooped spooned,last salt slat,ablest bleats stable tables'

(sorry for the long lines...) {edit} I added some breaks into the big lines, just reassemble them when you copy/paste! {/edit}

and it turned out like this:

code:
1a a1
2a a2
3a a3
4a a4
5a a5
6a a6
7a a7
8a a8
9a a9
feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
UDF passed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test
The Anagram() UDF passed validation
kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf v3.0.2 score = 454

So I guess it DOES work with more than 10...

It does not work with anagrams returning more than 10 words (that's the purpose of $d - count the words in the anagram to be returned) so as to sort the results by number of words 1st)

And because that could happen
quote:
Each set of anagrams will not exceed 15 words per anagram
I decided to make a test case for that too:

code:
$inputarray='0123456789abcdef,123456789abcdef0,23456789abcdef01,3456789abcdef012,
456789abcdef0123,56789abcdef01234,6789abcdef012345,789abcdef0123456,89abcdef01234567,
9abcdef012345678,admirer,parental,whatever,trifles,repost,kixtart,raddle,lifters,tartkiz,
atrophied,filters,warez,perseus,paternal,married,with,children,larded,hoes,poster,hose,
filets,prenatal,parlante,itself,stifler,aphrodite,stifle,portes,shoe,ladder,peruses,presto'

$correctoutput='admirer married,aphrodite atrophied,perseus peruses,filets itself stifle,
hoes hose shoe,ladder larded raddle,filters lifters stifler trifles,
parental parlante paternal prenatal,portes poster presto repost,0123456789abcdef
123456789abcdef0 23456789abcdef01 3456789abcdef012 456789abcdef0123 56789abcdef01234
6789abcdef012345 789abcdef0123456 89abcdef01234567 9abcdef012345678';

{edit} same as above... {/edit} And, as you said, it won't work on this one...

In that case, the code has to go "back" to a previous state with a score of 460 by sealeopard... And in this one, I can't cut any more bytes... [Frown]

Later,
Madruga

But that does give me another idea for KixGolf 3.0.3... [Smile] Be back soon...

[ 24. August 2002, 14:29: Message edited by: Fernando Madruga ]


Fernando Madruga
(Starting to like KiXtart)
2002-08-24 02:14 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Now for an updated (3.0.3) version of KiXGolf 3...

This version now prints the KiXtart version under wich it was started, like this:
code:
KixGolf v3.0.3 score = 460, running under KiXtart v4.10
{edit} another example:
KixGolf v3.0.3 score = 460, running under KiXtart v4.11 RC 1
{/edit}

And here it is:
code:
; KixGolf.kix  (Version 3)
;
$Version = "3.0.3" ; (2002/08/24@13:15) - Fernando Madruga
; Now prints KiXtart version too
;
;$Version = "3.0.2" ; (2002/08/23@18:45) - Fernando Madruga
; Now prints the version code with the score
;
; V 3.0.1 (2002/08/23@18:30) - Fernando Madruga
; Fixed handling of CHR(127) and added version info
;
; This function scores the specified file and returns
; the KixGolf score. That is the total number of key strokes
; used to build a script not counting comments, spaces, tabs,
; or any ASCII character above 126.
;
; The script will start counting on "odd" (1,3,5,...) occurrences
; of ";!" and the script will stop counting after "even" (0,2,4,...)
; instances of ";!". Note that ";!" must be placed starting in column
; number 1.
;
;A debug mode has been added in this version. The debug mode
;is controlled with the use of ";~" at the beginning of the line like
; the count controller (;!) above. You start and stop debugging
;as many time as you like while counting is enabled.
;
;Debug data is written to a file in the same directory that this
;program resides. The file name is that of the target file name with
;".debug" as an extension. Data will only be written while counting is
;active.
;
;The data written if the character being analyzed, it's ASCII decimal
;value, if it was counted or not, and a running total.
;
;Syntax: %tmp%\kix32 kixgolf.kix $F=Kixgolf.kix
;


; $F must be initialized on the command line.
; Syntax: kix32 kixgolf.kix $F=test.kix
?
? "KixGolf v" + $Version + " score = " + KixGolf($F) + ", running under KiXtart v" + @KIX
?

;!
Function KixGolf($F)
$debugfile=@ScriptDir+"\"+$F+".debug"
Del $debugfile
$Line=0
$Y=0 $D=0 $S=0
if open (1,$F) = 0
Do
if $L
$Line = $Line + 1
$ZZ = (left($L,2)=";~")
$debug = $debug + $ZZ & 1
if $debug & $olddebug<>$debug
WriteLog2($debugfile,"Debug Started at Line: " + $Line,1)
WriteLog2($debugfile,"--------------------------------------------------")
$olddebug=$debug
endif
if not $debug & $olddebug<>$debug
WriteLog2($debugfile,"--------------------------------------------------")
WriteLog2($debugfile,"Debug Stopped at Line: " + $Line,1)
$olddebug=$debug
endif
$Z = (left($L,2)=";!")
$Y = $Y + $Z & 1
if not $Z & not $ZZ
$x=len($L)
for $h=1 to $x
$A=asc(substr($L,$h,1))-32
$D = $D + ($A=2) & 1 & not $S
$S = $S + ($A=7) & 1 & not $D
if $debug
$Q = $D | $S
if $Q<>$oldQ
if $Q
WriteLog2($debugfile,"Quotes ON at: " + chr($A+32))
else
WriteLog2($debugfile,"Quotes OFF at: " + chr($A+32))
endif
endif
$oldQ=$Q
endif
if not $D & not $S & ($A=27)
$h=$x+1
if $debug
WriteLog2($debugfile,chr($A+32) + " " + ($A+32) + " Count=0 ")
$text="Comment found. Ignore to EOL. Next character should be" +
" 1st char of new line."
WriteLog2($debugfile,$text)
endif
else
$=$+($Y & (($A>0 & $A<96) | $D | $S))
if $debug
$text=chr($A+32) + " " + ($A+32) + " Count=" +
($Y & (($A>0 & $A<96) | $D | $S)) + " " + $
WriteLog2($debugfile,$text)
endif
endif
next
endif
endif
$L=ReadLine(1)
Until @error
else
"Bad File Name: $F" ?
$="NA"
endif
if $D | $S
? "Mis-matched quotes. Probable score error." ?
endif
if $olddebug
? "Debug File: " +$debugfile ?
endif
$KixGolf=$
EndFunction

;--------------------------------------------------------------------------------------------------
;FUNCTION WriteLog2()
;
;AUTHOR Howard A. Bullock (hbullock@tycoelectronics.com)
;
;ACTION Generic logging facility for scripts. Appends log entry to a file with an
; optional TimeStamp.
;
;SYNTAX WriteLog2($File, $text, [0|1])
;
;PARAMETERS $File (Required) - String value
; $text (Required) - String value
; $TimeStamp (Optional) Default(0) no TimeStamp (1 or 0)
;
;
;REMARKS This function writes (appends) an optionally time stamped log entry to the file
; defined in function. This function searches for the first unused file handle,
; open the file, and write the entry. The file handle is then closed. When the
; function is unable to perform its it write the error is displayed in a message box.
;
;RETURNS Nothing
;
;DEPENDENCIES None
;
;EXAMPLES WriteLog2("junk.txt","This is a test")
; WriteLog2("junk.txt","This is a test",0)
; WriteLog2("junk.txt","This is a test",1)
;
;
Function WriteLog2($File, $Text, optional $TimeStamp)
dim $RC, $File, $text, $FH, $TimeStamp
$FH=1
$RC=Open ($FH, $File, 5)
while $RC = -3
$FH=$FH +1
$RC=Open ($FH, $File, 5)
Loop
Select
Case $RC=0
if ($TimeStamp=1)
$TimeStamp = @Date + " " + @Time + " - "
else
$TimeStamp = ""
endif
$RC=Writeline ($FH, $TimeStamp + $Text + @CRLF)
$RC=Close ($FH)
Case $RC=-2
$text = "WriteLog2: Invalid file handle ($FH) specified when trying to Open $File."
$RC=MessageBox ($text,"Script Error",48)
Case $RC=-1
$text = "WriteLog2: Invalid file name ($File) specified for log file."
$RC=MessageBox ($text,"Script Error",48)
Case $RC=>0
$text = "System Error($RC) while attempting to open log file ($File)."
$RC=MessageBox ($text,"Script Error",48)
Endselect
EndFunction
;--------------------------------------------------------------------------------------------------

Later,
Madruga

[ 24. August 2002, 14:20: Message edited by: Fernando Madruga ]


**DONOTDELETE**
(Lurker)
2002-08-24 02:53 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

First my apologies
I had amended the test data to check something and forgot about it!
I inserted 2 null elements and they are returned as anagrams in the 466 code and following.
Also the test for an empty array uses Redim $InputArray[0]
If this used Redim $InputArray[5] (as I presumed in original coding)
it would fail in the 466 code and following

Your second interpretation of my 'more than 10 anagrams' was the one meant.
Namely an output line with more than 9 words on it will begin with a space character


**DONOTDELETE**
(Lurker)
2002-08-24 03:37 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Just a note about the scoring program.
From 4.10 you can use @ScriptName to get the name of the running program.
If KixGolf is in your udf library, you can just use it in your test program and
@ScriptName will be the name of your test script.
I use my scoring program this way, and run scripts from my editing session
(it saves the file to disk before executing it and so ReadLine picks up the
current state of the edited script).


Sealeopard
(KiX Master)
2002-08-24 06:11 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Just to make sure, the Anagram UDF must be able to handle up to 15 anagrams per set (though I haven't yet been able to find 15 anagrams to the same word since I don't know that many 15+ character English words).

[ 24. August 2002, 18:14: Message edited by: sealeopard ]


**DONOTDELETE**
(Lurker)
2002-08-24 07:50 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I found this from a review of the Chambers dictionary

Most mutual anagrams (9)
aster a plant
earst formerly
reast to become rancid
resat sat an examination again
stare a fixed look
stear a young ox
strae dried stalks of corn
Taser a small gunlike device
teras a monstrosity


Sealeopard
(KiX Master)
2002-08-25 05:19 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Time's up, and here are the results:

Part I:
1) 487 = AJH
2) 495 = Lonkero
3) 625 = Howard Bullock
4) 742 = Sealeopard

This makes AJH the winner of the first round with Lonkero a close second.

Part II
454 = Fernando Madruga
457 = MightyR1 (based on Fernando Madruga)
460 = Sealeopard (based on Fernando Madruga)
463 = Fernando Madruga (based on Lonkero)
466 = Lonkero
471 = Lonkero (based on AJH)
472 = AJH
484 = Lonkero (based on AJH)
487 = AJH
495 = Lonkero
554 = Richard Howarth
625 = Howard Bullock
702 = Sealeopard

First of all, welcome to our newest competitor Fernando Madruga, who some of you already know from the Win32 Perl mailing list.

Secondly, he provided the shortest script for the second part for a final winning score of 454.

I will also incorporate some improvements into the next KiXtart Golf namely a) the inclusion of the KiXtart version used to run the particualr script, b) if a posted script is being improved then the author of the originating script must be named, and c) the original author of the script with the final lowest score will get credits, too.

Thus, we would end up with three potential winners:
1) Winner of KiXtart Golf Part I
2) Winner of KiXtart Golf Part II
3) Original Author of winning script for 2)

[ 25. August 2002, 20:12: Message edited by: sealeopard ]


Fernando Madruga
(Starting to like KiXtart)
2002-08-25 07:29 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Hi folks!

I took some time to do some anagraming in perl [Smile] and I found the following
anagrams with 10 or more words based on an english word list file (YAWL) that
I download from Yet Another Word List.
I then made a perl program to calculate all possible anagrams and fed this
file containing more than 263.000 words to it. Here are the results for
words with 10 or more anagrams:

code:
010:angries earings erasing gainers graines
reagins regains reginas searing seringa
010:angriest astringe ganister gantries granites
ingrates rangiest reasting stearing tasering
010:easting eatings gainest genista ingates ingesta
seating tangies teasing tsigane
010:ester reest reset retes steer stere teers teres
terse trees
010:estrin inerts insert inters niters nitres sinter
strine triens trines
010:lapse leaps pales peals pelas pleas salep sepal
spale speal
011:anestri antsier nastier ratines resiant retains
retinas retsina stainer starnie stearin
011:palest palets pastel peltas petals plaste plates
pleats septal staple tepals
012:least leats salet setal slate stale steal stela
taels tales teals tesla
013:alerts alters artels estral laster rastle ratels
salter slater staler stelar talers tarsel
013:apers apres asper pares parse pears prase presa
rapes reaps spaer spare spear
013:arets aster earst rates reast resat stare stear
strae tares taser tears teras

So, if these were to be taken into consideration and the anagram_test
script were to be changed to use one of these, then the final scores
would be somewhat changed because the final set of codes
(after CHR($d) changed into $d) won't work with these...

If someone wants the perl code to play around (and yes, I know this
is not a perl BB, but this kind of script would have taken me AGES
to do in KiXtart!), please let me know and I'll post it. On my PC
(a PIII@1.100MHz with 512MB) only takes 11 seconds to read in the
263.000+ words file and put out the 20.639 possible anagrams! [Smile]

You can even use it just to look for anagrams for a given word, or
restrict anagrams only for words between x and y characters, based
on the dictionary provided. (And, of course, you can use your own
dictionary!)

Also, back to the contest, where it says:
quote:
463 = Fernando Madruga
, it should say
463 = Fernando Madruga (based on 466 by Lonkero).

Later,
Madruga

[ 25. August 2002, 19:33: Message edited by: Fernando Madruga ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-26 10:17 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

well, if we see the rules, didn't it say that the anagrams may grow up to 15 words?

or did I read them wrong?


Sealeopard
(KiX Master)
2002-08-26 03:45 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Yes, that is true. Up to 15 anagrams per set with multiple sets.

BrianTX
(Korg Regular)
2002-08-26 08:30 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Man! I missed it.. was too busy keeping up with girlfriend/work duties/family stuff.. Someone notify me next time you hold one of these! [Smile]

Brian


Sealeopard
(KiX Master)
2002-08-26 08:39 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Brian: We've been missing you (actualy, Lonkero missed you).

Anyway, I'll announce it a week in advance the next time, unless you'll be gone for more than a week at a time again.


BrianTX
(Korg Regular)
2002-08-26 08:52 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

I suppose I'll have to check in more often. It's nice stopping by and seeing all the hard work you guys have put into coding for kixtart.

Brian


Fernando Madruga
(Starting to like KiXtart)
2002-08-26 08:53 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Actually, I 1st started the "quest for the 15th anagram" to see if there was such a thing... Unfortunately for me (score wise), even though there is no such thing (in English) there are quite some few with 10 or more... [Frown]

Later,
Madruga

P.S.: Maybe sealeopard can update his anagram_test to include one of these? (Should have been there from the start! Or at least, should have an x anagram test where the rules would say "it can be up to x words..." [Smile]


LonkeroAdministrator
(KiX Master Guru)
2002-08-26 09:52 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

so, what is the winning code now?
the one with 463?


Fernando Madruga
(Starting to like KiXtart)
2002-08-27 01:16 AM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)

Well, since nobody else seems willing to do it, I decided to
grab anagram_test.kix and "update" it to include one of the
13 word anagrams.

(look below for updated script)

As for the results (still running under 4.11 RC 1 ):
code:
feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
alerts alters artels estral laster rastle ratels salter slater
staler stelar talers tarsel
UDF passed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test

The Anagram() UDF passed validation

kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf v3.0.3 score = 466, running under KiXtart v4.11 RC 1
-----------------------------------
feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
alerts alters artels estral laster rastle ratels salter slater
staler stelar talers tarsel
UDF passed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test

The Anagram() UDF passed validation

kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf v3.0.3 score = 463, running under KiXtart v4.11 RC 1
-----------------------------------
feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
alerts alters artels estral laster rastle ratels salter slater
staler stelar talers tarsel
UDF passed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test

The Anagram() UDF passed validation

kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf v3.0.3 score = 460, running under KiXtart v4.11 RC 1
-----------------------------------

alerts alters artels estral laster rastle ratels salter slater
staler stelar talers tarsel
The output array element alerts alters artels estral laster rastle
ratels salter slater staler stelincorrect tarsel is
feeling fleeing
The output array element feeling fleeing is incorrect
snooped spooned
The output array element snooped spooned is incorrect
last salt slat
The output array element last salt slat is incorrect
ablest bleats stable tables
The output array element ablest bleats stable tables is incorrect
UDF failed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test

The Anagram() UDF failed validation

kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf v3.0.3 score = 457, running under KiXtart v4.11 RC 1
-----------------------------------

alerts alters artels estral laster rastle ratels salter slater
staler stelar talers tarsel
The output array element alerts alters artels estral laster rastle
ratels salter slater staler stelincorrect tarsel is
feeling fleeing
The output array element feeling fleeing is incorrect
snooped spooned
The output array element snooped spooned is incorrect
last salt slat
The output array element last salt slat is incorrect
ablest bleats stable tables
The output array element ablest bleats stable tables is incorrect
UDF failed regular input array test
admirer married
aphrodite atrophied
perseus peruses
filets itself stifle
hoes hose shoe
ladder larded raddle
filters lifters stifler trifles
parental parlante paternal prenatal
portes poster presto repost
UDF passed another regular input array test
UDF passed empty input array test
UDF passed empty input string test
UDF passed no anagram input array test

The Anagram() UDF failed validation

kix32 Kixgolf3.kix $f=anagram_test.kix

KixGolf v3.0.3 score = 454, running under KiXtart v4.11 RC 1
-----------------------------------

So, as you all can see from this long post, the last code passing
all tests is 460 by sealeopard based on ??? by ???
(getting too lazy to look elsewhere for this info! [Smile] )

HTH,
Madruga

P.S.: Forgot to include the updated anagram_test.
In order to keep this short, I'll just include
the two changed lines from the 1st set of tests:
code:
 
; these were wrapped for display!

$inputarray='gas,bleats,stable,fleeing,artels,ratels,alters,talers,
ablest,spiff,hack,stelar,staler,tables,feeling,spooned,snooped,grep,
estral,alerts,tarsel,slat,salt,last,salter,slater,laster,rastle,drive'

$correctoutput='feeling fleeing,snooped spooned,last salt slat,
ablest bleats stable tables,alerts alters artels estral laster
rastle ratels salter slater staler stelar talers tarsel'



[ 27. August 2002, 01:22: Message edited by: Fernando Madruga ]