Sealeopard
(KiX Master)
2002-08-17 10:03 PM
KiXtart Golf Tournament IV: Anagrams

KiXtart Golf IV: Anagrams

The general KiXtart Golf rules are at the end of the post. Following are the goal and rules for the current KiXtart Golf challange.

Goal
Find all the anagrams in a given input array and display them in the specified format.

An anagram is a word (or phrase, but we'll stick with words for this contest) formed by rearranging the letters of another word (or phrase). For example, elvis and lives.

Rules
The input file is an array of words, one word per array element. Each word consists of [a-z] only.

Each input array element consists of the word only, with no leading or trailing whitespace, and no empty lines (unless the array or array element is empty).

Please note that the input array can be empty.

You may not assume that the input array will be sorted.

You are to return the anagrams found, one space-delimited array element for each set.

You are to print the anagrams and only the anagrams: you are to discard standalone words with no anagrams.

A array element of the output array consists of all the words that anagrams the others: each word is separated by one space (no leading/trailing space allowed).

Each set of anagrams will not exceed 15 words per anagram.

The words on each output array element will be sorted alphabetically.

The output array elements are first sorted by number of words (the fewer first), then alphabetically using the first word of the line (after the line itself is sorted alphabetically).

The program may use any version of KiXtart up to and including the latest beta versions (currently KiXtart 4.11 beta 2)

The prototye for the function is as follows:
code:
$outputarray=Anagram($inputarray)

Example
Given the input:

hack
snooped
tables
salt
spiff
feeling
spooned
last
grep
bleats
gas
ablest
fleeing
stable
slat
drive

You are to output the following:

feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables

Test Code
code:
BREAK ON

DIM $rc, $inputarray, $correctoutput, $outputarray, $line, $error

$rc=SETOPTION('Explicit','ON')
$rc=SETOPTION('NoVarsInString','ON')

$inputarray='hack,snooped,tables,salt,spiff,feeling,spooned,last,grep,bleats,gas,ablest,fleeing,stable,slat,drive'
$correctoutput='feeling fleeing,snooped spooned,last salt slat,ablest bleats stable tables'

$inputarray=SPLIT($inputarray,',')
$correctoutput=SPLIT($correctoutput,',')

$outputarray=Anagram($inputarray)

IF UBOUND($outputarray)=UBOUND($correctoutput)
FOR $line=0 TO UBOUND($outputarray)
? $outputarray[$line]
IF $outputarray[$line]<>$correctoutput[$line]
$error=1
ENDIF
NEXT
ELSE
$errror=1
ENDIF

IF $error
? 'The output array is not correct'
ELSE
? 'The Anagram() UDF passed validation'
ENDIF

; beginning of the Anagram() UDF and supporting UDFs
; end of the Anagram() UDF and supporting UDFs

================================================================
KiXtart GOLF - How To Play
================================================================


Most importantly, anybody can play, no age restrictions, no penalties, no handicap!

The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.

Example: How many positive elements are in array $a?

Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9]

One approach:
code:
for $b=0 to ubound($a)
if $a[$b]>0
$c=$c+1
endif
next

for a score of 45.

Another solution is:
code]DO
$b=$b+1
if $a[$b]>0
$c=$c+1
endif
UNTIL $b>(UBOUND($a)+1)[/code]

for a score of 53.

Better approach: Code sample 1

================================================================
KiXtart GOLF - The Rules
================================================================


1) The goal of KiXtart Golf is to score the lowest strokes.

2) Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count or spaces in between the '=' sign when assigning variables, e.g. '$a = $b' scores 5.

3) Code can be constructed any way you like, as long as it is syntactically correct with KiXtart.

4) The final solution MUST pass all test scripts that accompagny the KiXtart golf challenge.

5) The use of '$' as a variable is allowed.

6) In case of questions about a particular way to count the KiXtart Golf Challenge organizer has the last call.

7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player.

8) During the public coding phase, code should be posted, reused, and borrowed from other players.

9) The following script can be used to count the KiXtart Golf score: http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=003608

================================================================
KiXtart GOLF - The Duration of the Competition
================================================================


1) Private coding phase: From date/time of posting the tournament challenge to the following Wednesday, 3pm EST (BBS+6 time)

2) Public coding phase: From Wednesday 3pm EST (BBS+6 time) to the following Sunday, 7pm EST (BBS+6 time)

3) Final results: The following Monday, 11am EST (BBS+6 time)

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


Sealeopard
(KiX Master)
2002-08-17 10:30 PM
Re: KiXtart Golf Tournament IV: Anagrams

AJ:

This will NOT require a dictionary since you are only comparing the provided words. So, if I have the words ELVIS, LIVES, SILVER then the algorithm should be able to figure out that ELVIS is an anagram of LIVES and that SILVER is not an anagram of either ELVIS or LIVES. The algorithm is not supposed to find that SLIVER is an anagram of SILVER since SLIVER wasn't provided in the list of words.


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 12:01 AM
Re: KiXtart Golf Tournament IV: Anagrams

again (I think I said this last time too), isn't the actual number V not IV...


[ 18. August 2002, 00:06: Message edited by: Lonkero ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 01:27 AM
Re: KiXtart Golf Tournament IV: Anagrams

got it pretty much done on paper...

just can't figure the use for sorting.
it should double my code...


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 02:25 AM
Re: KiXtart Golf Tournament IV: Anagrams

I think there is something wrong with the validation code...

I don't have the sort yet in my code but wanted to check how it comes out with current state.

there was no output at all but it just said that my udf passed the validation...


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 05:28 AM
Re: KiXtart Golf Tournament IV: Anagrams

huh. currently the sorting has got my code tribled and it's not even working properly yet.

guys, are you all sleeping or what?

I miss brian as he was a competition even at night time... just wonder what hoby might be doing...


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 06:18 AM
Re: KiXtart Golf Tournament IV: Anagrams

ok, first working code.

score: 548

now I'll start playing with forms2.0 beta.

[ 18. August 2002, 06:33: Message edited by: Lonkero ]


Sealeopard
(KiX Master)
2002-08-18 03:19 PM
Re: KiXtart Golf Tournament IV: Anagrams

Lonkero:

If $outputarray is empty, then yes, it'll tell you that your UDF passed. I will update the code to reflect the case of $outputarray being empty.


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 04:56 PM
Re: KiXtart Golf Tournament IV: Anagrams

mmm...
also, if the array is less than 4 elements, it gets passed.
hoby, your version 3 of the golfcounter is lot harder to use as you can't use it directly on commandline without adding the line:
kixgolf($F)
into the start.
neither putting it to the udf-file did not work as then it errored out.

Golf Score: 531


Howard Bullock
(KiX Supporter)
2002-08-18 05:08 PM
Re: KiXtart Golf Tournament IV: Anagrams

Lonkero, I use KicGolf3.kix like this so that it reports the score after each test execution.
code:
Jens' Kix code...

shell "C:\Data\Kix2001\KiX2001.410\kix32 c:\data\scripts\Kixgolf3.kix $f=@scriptname"
; beginning of the Anagram() UDF and supporting UDFs
;!
Code...
;!
; end of the Anagram() UDF and supporting UDFs



LonkeroAdministrator
(KiX Master Guru)
2002-08-18 05:10 PM
Re: KiXtart Golf Tournament IV: Anagrams

yeah, that's what I mean... there is need to play with shell.

well, as long as it counts faster than me, it will do.


Howard Bullock
(KiX Supporter)
2002-08-18 05:59 PM
Re: KiXtart Golf Tournament IV: Anagrams

Well Jooel, I have working code, but nowhere near as tight as yours.

KixGolf score = 1851


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 06:03 PM
Re: KiXtart Golf Tournament IV: Anagrams

well, currently at 523 but can't cut it anymore...

head hearts already and we have still something like 80 hours to code.


Howard Bullock
(KiX Supporter)
2002-08-18 06:06 PM
Re: KiXtart Golf Tournament IV: Anagrams

At least I can see some progress being made in my code during the next 80 hours. [Big Grin] Too bad your code is so good. [Eek!]

LonkeroAdministrator
(KiX Master Guru)
2002-08-18 06:08 PM
Re: KiXtart Golf Tournament IV: Anagrams

well,
I'm waiting... and I'm afraid that brian is going to show up suddenly tomorrow and beat me.
and still, even though it seems to work correctly, there can be a bug...

Golf Score: 515


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 06:10 PM
Re: KiXtart Golf Tournament IV: Anagrams

btw, I was going over 1000 when tried to get that sorting working.
then found some nice tricks and here is the result.

as the actual anagram finding code is only 180-200 scores


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 07:16 PM
Re: KiXtart Golf Tournament IV: Anagrams

hoby, still there?

Golf Score: 484


**DONOTDELETE**
(Lurker)
2002-08-18 07:20 PM
Re: KiXtart Golf Tournament IV: Anagrams

Well I was hoping to get one over on Lonkero with 527,
but I wasn't fast enough!


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 07:35 PM
Re: KiXtart Golf Tournament IV: Anagrams

good god!

you're getting really close and my code is hard to get even one stroke shorter!


Sealeopard
(KiX Master)
2002-08-18 08:25 PM
Re: KiXtart Golf Tournament IV: Anagrams

Okay folks, here's my preliminary score. It's for a working code without variable name reductions:

KiXtart Golf Score=1458


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 08:45 PM
Re: KiXtart Golf Tournament IV: Anagrams

Golf Score: 483

{edit 21:23}
Golf Score: 482

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


MightyR1
(MM club member)
2002-08-18 09:49 PM
Re: KiXtart Golf Tournament IV: Anagrams

Jens,

what if the number of words in a set exceeds 15?

discard the rest or make a set of 15 and a set of the rest? How must this be printed?


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 09:56 PM
Re: KiXtart Golf Tournament IV: Anagrams

well, I understood that it will not exceed.
means no checking for that is needed.
also, it may and may not work for with longer ones too.
I tested my shortest code with:
$inputarray='hack,snooped,tables,salt,spiff,tnipr,feeling,spooned,last,print,intpr,grep,bleats,gas,ablest,fleeing,stable,slat,drive,rpitn'


and output was:

feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
intpr print rpitn tnipr


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


**DONOTDELETE**
(Lurker)
2002-08-18 10:37 PM
Re: KiXtart Golf Tournament IV: Anagrams

Golf Score 507
Can't seem to break the magic 500 barrier


LonkeroAdministrator
(KiX Master Guru)
2002-08-18 11:06 PM
Re: KiXtart Golf Tournament IV: Anagrams

I have some difficulties here too.

I tried changing and compining and mixing.
got it to work but scores went to 490...

can't seem to cut this anymore.


LonkeroAdministrator
(KiX Master Guru)
2002-08-19 01:03 AM
Re: KiXtart Golf Tournament IV: Anagrams

now it's done. after three hours of playing with simple if statement saves one stroke getting me to
Golf Score: 481

{edit [02:20 finnish time]}
duh.
numbers are lovely strings...
Golf Score: 479

{edit 02:45}
I quess it's time for me to go to bed...
Golf Score: 473

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


**DONOTDELETE**
(Lurker)
2002-08-19 07:59 PM
Re: KiXtart Golf Tournament IV: Anagrams

Golf score = 483
only 10 behind!

Jens - Technical question.

If the input array is empty or there are no matches,
what do you want returned ?

a) An unassigned variable (VarType = Empty)
b) An empty string (VarType = String)
c) An array containing only (a) above*
d) An array containing only (b) above*

(* array consists of one dimension ie UBOUND($OutputArray) = 0)

[ 19. August 2002, 21:14: Message edited by: AJH ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-19 09:26 PM
Re: KiXtart Golf Tournament IV: Anagrams

I think then the output should be empty...
or 0 lenght string or something like that...


Sealeopard
(KiX Master)
2002-08-19 09:31 PM
Re: KiXtart Golf Tournament IV: Anagrams

If the input string is empty, then the output string is empty. If the input array is empty, then the output string is empty.

LonkeroAdministrator
(KiX Master Guru)
2002-08-19 09:58 PM
Re: KiXtart Golf Tournament IV: Anagrams

ajh, I leave you in peace.

I left my laptop at work and at home have only linux-server.
this means, you can freely try to beat my score.
I have to sleep.

as you got so close I can assume only that your code is same as mine before... or it uses really fully different syntax. if latter, you might even get ahead of me.


**DONOTDELETE**
(Lurker)
2002-08-20 01:15 AM
Re: KiXtart Golf Tournament IV: Anagrams

If I read Jens correctly then no anagrams should produce a variable as the result
(vartype 'Empty' Ubound = -1), and I have a score of 477
(so near and yet so far [Frown] ).
If on the other hand no anagrams can produce an empty array
(vartype = Variant[] with Ubound = 0, Result[0] = Empty)
then I can get 468.

So Lonkero still rules!


Sealeopard
(KiX Master)
2002-08-20 04:13 AM
Re: KiXtart Golf Tournament IV: Anagrams

AJH:

I don't think you read it correctly, I specified that the OUTPUT STRING is empty, thus VARTYPE=8.

Anyway, below is a more extensive validation script. It checks four different conditions
1) Anagrams (as provided in the firts post)
2) Empty input string
3) Empty input array
4) Input string with words but not containing any anagrams

My score is now 742 passing all four conditions and I have absolutely no clue how to cut out about 1/3rd of my code to come close to you guys [Wink]

code:
BREAK ON

DIM $rc, $inputarray, $correctoutput, $outputarray, $line
DIM $error1, $error2, $error3, $error4, $shellcommand

$rc=SETOPTION('Explicit','ON')
$rc=SETOPTION('NoVarsInString','ON')


; begin testing with regular array
$inputarray='hack,snooped,tables,salt,spiff,feeling,spooned,last,grep,bleats,gas,ablest,fleeing,stable,slat,drive'
$correctoutput='feeling fleeing,snooped spooned,last salt slat,ablest bleats stable tables'

$inputarray=SPLIT($inputarray,',')
$correctoutput=SPLIT($correctoutput,',')

$outputarray=Anagram($inputarray)

IF UBOUND($outputarray)=UBOUND($correctoutput)
FOR $line=0 TO UBOUND($outputarray)
? $outputarray[$line]+' = '+$correctoutput[$line]
IF $outputarray[$line]<>$correctoutput[$line]
? 'The output array element '+$outputarray[$line]+' is incorrect'
$error1=1
ENDIF
NEXT
ELSE
? 'The output array has an incorret size of '+UBOUND($outputarray)
$error1=1
ENDIF
if $error1
color r+/n
? 'UDF failed regular input array test'
color w/n
else
? 'UDF passed regular input array test'
endif
; end testing with regular array


; begin testing with empty array
redim $inputarray[10]
$correctoutput=''

$outputarray=Anagram($inputarray)

if $outputarray<>$correctoutput
? 'The output array is not empty'
$error2=1
ENDIF
if $error2
color r+/n
? 'UDF failed empty input array test'
color w/n
else
? 'UDF passed empty input array test'
endif
; end testing with empty array


; begin testing with empty string
$inputarray=''
$correctoutput=''

$outputarray=Anagram($inputarray)

IF $outputarray<>$correctoutput
? 'The output array is not empty'
$error3=1
ENDIF
if $error3
color r+/n
? 'UDF failed empty input string test'
color w/n
else
? 'UDF passed empty input string test'
endif
; end testing with empty string

; begin testing with array of no anagrams
$inputarray='test,testing,tester,store'
$inputarray=SPLIT($inputarray,',')
$correctoutput=''

$outputarray=Anagram($inputarray)

IF UBOUND($outputarray)=UBOUND($correctoutput)
FOR $line=0 TO UBOUND($outputarray)
? $outputarray[$line]+' = '+$correctoutput[$line]
IF $outputarray[$line]<>$correctoutput[$line]
? 'The output array element '+$outputarray[$line]+' is incorrect'
$error4=1
ENDIF
NEXT
ELSE
? 'The output array has an incorret size of '+UBOUND($outputarray)
$error4=1
ENDIF
if $error4
color r+/n
? 'UDF failed no anagram input array test'
color w/n
else
? 'UDF passed no anagram input array test'
endif
; end testing with array of no anagrams


IF $error1 or $error2 or $error3 or $error4
color r+/n
? 'The Anagram() UDF failed validation'
color w/n
ELSE
? 'The Anagram() UDF passed validation'
ENDIF

; if KiXGolf3.kix (the latest version of the kiXtart golf scoring script is in the same
; diretory as the KiXtart Golf script and the KiXtart executable then it'll display the
; official KiXtart golf score
$shellcommand=@scriptdir+'\kix32.exe '+@scriptdir+'\Kixgolf3.kix $f='+@scriptname
? $shellcommand
shell $shellcommand

; end of the kiXtart Golf validation script



LonkeroAdministrator
(KiX Master Guru)
2002-08-20 07:01 AM
Re: KiXtart Golf Tournament IV: Anagrams

AJH, How can I still rule if you are almost 10 ahead of me?
I also have code shrunk some much, I can't do anything to it anymore.

and I think my code size propably rises on the explicit string on output. uttleast 4 chars.


Howard Bullock
(KiX Supporter)
2002-08-20 09:04 AM
Re: KiXtart Golf Tournament IV: Anagrams

Still trying...

feeling fleeing
snooped spooned
last salt slat
ablest bleats stable tables
The Anagram() UDF passed validation

KixGolf score = 470

{edit}
KixGolf score = 467

{edit}
KixGolf score = 464

{edit}
KixGolf score = 462

{edit}
KixGolf score = 458

[ 20. August 2002, 09:34: Message edited by: Howard Bullock ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-20 09:34 AM
Re: KiXtart Golf Tournament IV: Anagrams

hoby, you seem to be rocking today.
I can't get any of the strokes out and you just cut them like they were just air.

I think I must start reorganizing my udf...


Howard Bullock
(KiX Supporter)
2002-08-20 09:36 AM
Re: KiXtart Golf Tournament IV: Anagrams

I soooo tired, but I can't stop. [Big Grin]

MightyR1
(MM club member)
2002-08-20 10:16 AM
Re: KiXtart Golf Tournament IV: Anagrams

Got it working without sorting; Score = 267

Be back later with sorting (if I get it working!)


LonkeroAdministrator
(KiX Master Guru)
2002-08-20 11:18 AM
Re: KiXtart Golf Tournament IV: Anagrams

heh...
pat, it just is that the sorting makes it big.

my script would be just 100 chars without it.


MightyR1
(MM club member)
2002-08-20 11:25 AM
Re: KiXtart Golf Tournament IV: Anagrams

just 100?? [Eek!]

Well I won't give up...


**DONOTDELETE**
(Lurker)
2002-08-20 04:03 PM
Re: KiXtart Golf Tournament IV: Anagrams

Jens 4 tests put me back up to 487 [Frown]

Sealeopard
(KiX Master)
2002-08-20 04:09 PM
Re: KiXtart Golf Tournament IV: Anagrams

Everybody:

Please test your Anagram scripts with KiXtart 4.11 RC-1. [Big Grin]

My script bombs with a line like this:
code:
$a=split($b,' ')[0]

It seems we lost the ability to directly reference an array element after a split operation. KiXtart 4.10a and KiXtart 4.11 beta 2 seem to work fine, though.

Anyway, now that your heart is racing, you are free to use any Kixtart version of your choosing.


Howard Bullock
(KiX Supporter)
2002-08-20 04:09 PM
Re: KiXtart Golf Tournament IV: Anagrams

What 4 tests? Jens only supplied one.

Still at:
KixGolf score = 458


kholm
(Korg Regular)
2002-08-20 04:24 PM
Re: KiXtart Golf Tournament IV: Anagrams

Jens,

Sad but true [Frown]

It seems that you are right, you can't directly reference a member from the split() function when using v. 4.11 rc1

-Erik


Sealeopard
(KiX Master)
2002-08-20 04:49 PM
Re: KiXtart Golf Tournament IV: Anagrams

Yeah, I'll report is as a bug [Wink]

Also, I ahve expanded my test suite again, this
time with more anagrams. The latest version of
th test suite is posted below and (because of
the extremely long lines) can also be downloaded
at http://people.bu.edu/jenmeyer/kixtart/anagram_test.zip

You will also need the KiXGolf3.kix file and
KiXtart in the same directory as the test
script. then just paste your Anagram UDF into
it, and it'll validate your UDF and spit out the
KiXtart golf score.

I'm done with my script, passing all five
validation test and achieving a test score of 742 and no way of shortening it.
code:
BREAK ON

DIM $rc, $inputarray, $correctoutput, $outputarray, $line
DIM $error1, $error2, $error3, $error4, $error5, $shellcommand

$rc=SETOPTION('Explicit','ON')
$rc=SETOPTION('NoVarsInString','ON')


; begin testing with regular array
$inputarray='hack,snooped,tables,salt,spiff,feeling,spooned,last,grep,bleats,gas,ablest,fleeing,stable,slat,drive'
$correctoutput='feeling fleeing,snooped spooned,last salt slat,ablest bleats stable tables'

$inputarray=SPLIT($inputarray,',')
$correctoutput=SPLIT($correctoutput,',')

$outputarray=Anagram($inputarray)

IF UBOUND($outputarray)=UBOUND($correctoutput)
FOR $line=0 TO UBOUND($outputarray)
? $outputarray[$line]
IF $outputarray[$line]<>$correctoutput[$line]
? 'The output array element '+$outputarray[$line]+' is incorrect'
$error1=1
ENDIF
NEXT
ELSE
? 'The output array has an incorret size of '+UBOUND($outputarray)
$error1=1
ENDIF
if $error1
color r+/n
? 'UDF failed regular input array test'
color w/n
else
? 'UDF passed regular input array test'
endif
; end testing with regular array

; begin testing with another regular array
$inputarray='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'

$inputarray=SPLIT($inputarray,',')
$correctoutput=SPLIT($correctoutput,',')

$outputarray=Anagram($inputarray)

IF UBOUND($outputarray)=UBOUND($correctoutput)
FOR $line=0 TO UBOUND($outputarray)
? $outputarray[$line]
IF $outputarray[$line]<>$correctoutput[$line]
? 'The output array element '+$outputarray[$line]+' is incorrect'
$error2=1
ENDIF
NEXT
ELSE
? 'The output array has an incorret size of '+UBOUND($outputarray)
$error2=1
ENDIF
if $error2
color r+/n
? 'UDF failed another regular input array test'
color w/n
else
? 'UDF passed another regular input array test'
endif
; end testing with another regular array

; begin testing with empty array
redim $inputarray[0]
$correctoutput=''

$outputarray=Anagram($inputarray)

if $outputarray<>$correctoutput
? 'The output array is not empty'
$error3=1
ENDIF
if $error3
color r+/n
? 'UDF failed empty input array test'
color w/n
else
? 'UDF passed empty input array test'
endif
; end testing with empty array


; begin testing with empty string
$inputarray=''
$correctoutput=''

$outputarray=Anagram($inputarray)

IF $outputarray<>$correctoutput
? 'The output array is not empty'
$error4=1
ENDIF
if $error4
color r+/n
? 'UDF failed empty input string test'
color w/n
else
? 'UDF passed empty input string test'
endif
; end testing with empty string

; begin testing with array of no anagrams
$inputarray='test,testing,tester,store'
$inputarray=SPLIT($inputarray,',')
$correctoutput=''

$outputarray=Anagram($inputarray)

IF UBOUND($outputarray)=UBOUND($correctoutput)
FOR $line=0 TO UBOUND($outputarray)
? $outputarray[$line]+' = '+$correctoutput[$line]
IF $outputarray[$line]<>$correctoutput[$line]
? 'The output array element '+$outputarray[$line]+' is incorrect'
$error5=1
ENDIF
NEXT
ELSE
? 'The output array has an incorret size of '+UBOUND($outputarray)
$error5=1
ENDIF
if $error5
color r+/n
? 'UDF failed no anagram input array test'
color w/n
else
? 'UDF passed no anagram input array test'
endif
; end testing with array of no anagrams


IF $error1 or $error2 or $error3 or $error4 or $error5
color r+/n
? 'The Anagram() UDF failed validation'
color w/n
ELSE
? 'The Anagram() UDF passed validation'
ENDIF

$shellcommand=@scriptdir+'\kix32.exe '+@scriptdir+'\Kixgolf3.kix $f='+@scriptname
? $shellcommand
shell $shellcommand

; end of the kiXtart Golf validation script


; beginning of the Anagram() UDF and supporting UDFs
;!

;!
;!
; end of the Anagram() UDF and supporting UDFs



LonkeroAdministrator
(KiX Master Guru)
2002-08-20 06:19 PM
Re: KiXtart Golf Tournament IV: Anagrams

after changing my udf to return empty strings instead of empty arrays the score raised:

Golf Score: 495

I'll give this up as my script has had so many structures all the loops one can think of and so much weirdness...
can't compete anymore.


Howard Bullock
(KiX Supporter)
2002-08-20 07:19 PM
Re: KiXtart Golf Tournament IV: Anagrams

My score will probably being going up as well. I just ran Jens new validation code and only passed the first test.

[ 20. August 2002, 20:49: Message edited by: Howard Bullock ]


Sealeopard
(KiX Master)
2002-08-20 07:42 PM
Re: KiXtart Golf Tournament IV: Anagrams

Now that is strange, you should have passed the first and second test since they are just two different sets of anagrams.

Howard Bullock
(KiX Supporter)
2002-08-20 07:45 PM
Re: KiXtart Golf Tournament IV: Anagrams

I cheated on the half of the sorting since I was coding to the inital test only. My sorting algorithm succeeded in one step with the first array but could and did fail on a different mix of words.

[ 20. August 2002, 19:47: Message edited by: Howard Bullock ]


LonkeroAdministrator
(KiX Master Guru)
2002-08-20 08:43 PM
Re: KiXtart Golf Tournament IV: Anagrams

does that mean that I still have hope?

would like to hear AJH's current score too...


Howard Bullock
(KiX Supporter)
2002-08-21 07:27 AM
Re: KiXtart Golf Tournament IV: Anagrams

Started from scratch again.

C:\Data\Scripts\Golf>C:\Data\Kix2001\KiX2001.411b2\kix32 golf4.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

KixGolf score = 672

time to start tweaking [Big Grin]

{edit}
KixGolf score = 658

{edit}
KixGolf score = 653

{edit}
KixGolf score = 645

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


LonkeroAdministrator
(KiX Master Guru)
2002-08-21 08:28 AM
Re: KiXtart Golf Tournament IV: Anagrams

now, if ajh would just inform us where he is at.
otherwise I'll assume, I'm in lead again and rest this day.

anyway, if you get pass me, it's not that I didn't try, but I did best I could already at the weekend.
now, it's not compressable.


Howard Bullock
(KiX Supporter)
2002-08-21 08:16 PM
Re: KiXtart Golf Tournament IV: Anagrams

KixGolf score = 625

LonkeroAdministrator
(KiX Master Guru)
2002-08-21 08:24 PM
Re: KiXtart Golf Tournament IV: Anagrams

you are running out of time [Big Grin]

sadly, didn't take my laptop home so can't post the to be winning code until tomorrow. means 10 hours from now.

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


**DONOTDELETE**
(Lurker)
2002-08-21 08:26 PM
Re: KiXtart Golf Tournament IV: Anagrams

As stated previously
Current golf score = 487
Passes Jens 5 tests


LonkeroAdministrator
(KiX Master Guru)
2002-08-21 08:28 PM
Re: KiXtart Golf Tournament IV: Anagrams

oh, man I like to see your script.

can't think of what method you used on it...