#69145 - 2002-08-18 09:56 PM
Re: KiXtart Golf Tournament IV: Anagrams
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
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 ]
_________________________
!download KiXnet
|
Top
|
|
|
|
#69146 - 2002-08-18 10:37 PM
Re: KiXtart Golf Tournament IV: Anagrams
|
Anonymous
Anonymous
Unregistered
|
Golf Score 507 Can't seem to break the magic 500 barrier
|
Top
|
|
|
|
#69149 - 2002-08-19 07:59 PM
Re: KiXtart Golf Tournament IV: Anagrams
|
Anonymous
Anonymous
Unregistered
|
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 ]
|
Top
|
|
|
|
#69153 - 2002-08-20 01:15 AM
Re: KiXtart Golf Tournament IV: Anagrams
|
Anonymous
Anonymous
Unregistered
|
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 ). 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!
|
Top
|
|
|
|
#69154 - 2002-08-20 04:13 AM
Re: KiXtart Golf Tournament IV: Anagrams
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
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
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
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#69156 - 2002-08-20 09:04 AM
Re: KiXtart Golf Tournament IV: Anagrams
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
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 ]
|
Top
|
|
|
|
#69158 - 2002-08-20 09:36 AM
Re: KiXtart Golf Tournament IV: Anagrams
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I soooo tired, but I can't stop.
|
Top
|
|
|
|
#69162 - 2002-08-20 04:03 PM
Re: KiXtart Golf Tournament IV: Anagrams
|
Anonymous
Anonymous
Unregistered
|
Jens 4 tests put me back up to 487
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 259 anonymous users online.
|
|
|