Page 2 of 4 <1234>
Topic Options
#69292 - 2002-08-23 01:06 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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 ]
_________________________
Later,   [b]Mad[/b]ruga

Top
#69293 - 2002-08-23 01:39 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
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 ]
_________________________
!

download KiXnet

Top
#69294 - 2002-08-23 01:52 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
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 ]
_________________________
!

download KiXnet

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

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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
_________________________
Later,   [b]Mad[/b]ruga

Top
#69296 - 2002-08-23 02:14 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
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 ]
_________________________
!

download KiXnet

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

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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

_________________________
Later,   [b]Mad[/b]ruga

Top
#69298 - 2002-08-23 02:40 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
fernando, now we are talking.
thanks for this.

you will be hearing from us [Big Grin]
_________________________
!

download KiXnet

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

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
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 ]
_________________________
There are two types of vessels, submarines and targets.

Top
#69300 - 2002-08-23 02:59 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
with 4.11 beta 2 it says success. also with beta 1 and 4.10
_________________________
!

download KiXnet

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

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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 ]
_________________________
Later,   [b]Mad[/b]ruga

Top
#69302 - 2002-08-23 03:05 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
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.
_________________________
!

download KiXnet

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

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
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 ]
_________________________
There are two types of vessels, submarines and targets.

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

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
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 ]
_________________________
There are two types of vessels, submarines and targets.

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

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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
_________________________
Later,   [b]Mad[/b]ruga

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

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Yeah, 460, I guess it's enough computer screens for me now.
_________________________
There are two types of vessels, submarines and targets.

Top
#69307 - 2002-08-23 03:53 AM Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
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.
_________________________
!

download KiXnet

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

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
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

_________________________
Greetz,
Patrick Rutten

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

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

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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 ]
_________________________
Later,   [b]Mad[/b]ruga

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

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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 ]
_________________________
Later,   [b]Mad[/b]ruga

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

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
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 ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 2 of 4 <1234>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 173 anonymous users online.
Newest Members
EricMyers, siddharthinfosy, raynebc, MasterNinjaSkar, hienttt
17516 Registered Users

Generated in 0.236 seconds in which 0.124 seconds were spent on a total of 13 queries. Zlib compression enabled.

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