Page 5 of 6 « First<23456>
Topic Options
#66650 - 2002-06-11 10:53 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
$x = NOT
?

Yes...Script error: Error in expression.!
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66651 - 2002-06-11 11:21 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Oh man Erik, thats brilliant. And you might already know we had this exact problem a few months back, trying to pass IE a variant bool - and we ended with a really, really kludgey work-around, even going so far as to request that Ruud create a special macro call @TRUE and @FALSE.
Top
#66652 - 2002-06-11 11:31 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
shawn, now you can send e-mail to ruud that those are not needed anymore cause we have created our own variable declaration style [Smile]
_________________________
!

download KiXnet

Top
#66653 - 2002-06-12 03:37 AM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Unless someone can get the script I posted below 231, is this kixgolf over? Because I think I have a great idea (a VERY useful one, too), for the next kixgolf...

Brian

Top
#66654 - 2002-06-12 04:03 AM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Brian, you did a hell of a good job here.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66655 - 2002-06-12 04:47 AM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Thanks Howard! You did great, too. I wouldn't have done as well except you pushed me to the limit! lol

Brian

{hmm. let's not forget Shawn! Lots of great ideas there, too!}

[ 12 June 2002, 04:51: Message edited by: BrianTX ]

Top
#66656 - 2002-06-12 11:36 AM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
brian, it will be less...
_________________________
!

download KiXnet

Top
#66657 - 2002-06-13 12:50 AM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
DID IT!!!!

golf score:230!

code:
Function BaseConverter($v,$f,$t)
$=0
$y=1.
for $n=len($v) to 1 step -1
$x = ASC(UCASE(substr($v,$n,1)))
$=$y*($x - 48 - ($x > 64) * 7) +$
$y=$y*$f
next
$n=""
While $
$x = INT($ - (INT($/$t) * $t))
$ = ($-$x)/$t
$n = CHR($x + 48 + ($x > 9) * 7) + $n
Loop
$BaseConverter = $n
Endfunction

_________________________
!

download KiXnet

Top
#66658 - 2002-06-12 02:07 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jooel, how did you do it ? You shaved one more point off, right ? lol - I'm carrying this code fragment around in my pocket, taking it with me whereever I go, trying to shave just ONE MORE point - brain hurting ... eyes weary ... errgggg
Top
#66659 - 2002-06-12 02:20 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Way to go Jooel!

(I pretty much gave up on it because I was tired of messing with it! lol)
Now, if everyone is satisfied that it has been shrunk satisfactorily, we need to add error checking to make it useful to post... (of course, I would think we all should get credit for it!)..

Requirements:

1. All bases fall between 2 and 36
2. The numerals are all less than the base converting from
3. invalid characters (including the ones in the ascii chart between 0-9 and A-Z) are not accepted.
4. Anything falling outside of the accepted input range causes the function to exit with errorlevel 1 and empty string returned.
....

Brian

[ 12 June 2002, 15:05: Message edited by: BrianTX ]

Top
#66660 - 2002-06-12 02:28 PM Re: Round 2: KiXtart Golf Tournament Part III
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Brian, can you send me your ideas as a private message, please?

BTW, I will officially end this KiXtart Golf Tournament at 3pm Eastern Daylight Savings time wit a little recap, the final code, and maybe even some ff the tricks that have been used (unless my co-workers give me work-related things to do [Frown] )
_________________________
There are two types of vessels, submarines and targets.

Top
#66661 - 2002-06-12 02:42 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Going forward, we should try (maybe not always) to insure that these puzzles center around a usefull real-world problem, I mean, this whole excerise was just wonderfull, and to actually have a lite-weight, fast UDF at the end of it - gravy !
Top
#66662 - 2002-06-12 02:54 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
brian, I was trying to cut 3 more, but couldn't get it to work as my brains are in huge pain as well.

but,
to get it smaller one could try taken all the functioning to one loop and go on until adding and reducing has finished.
this means, that at the same time as the original fractions are being counted also the translation to the new one is carried out.
the fraction play got my head so mad I gave up.
but it would have been worth it.
think how much nicer it would look to have working code of 227 than the one now with 230 [Wink]
_________________________
!

download KiXnet

Top
#66663 - 2002-06-12 03:03 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here's another trick I used on the weekend, before rolling everything together. You know with a puzzle like this, that breaking the solution up into seperate UDF's can be VERY expensive in terms of chars. Well, here's an example of how we can "embed" functions within UDF themselves, example:

break on

?"func=" addone(1)

exit 1

function addone($n)

 gosub "add"

 $addone = $n

 return

 :add
  $n = $n + 1
 return

endfunction


This function just adds one to the number specified, but notice the gosub embedded inside the UDF itself. Heres the interesting thing, $n is local to the UDF, but the subroutine still has access to it. Even more interesting is that the GOSUB routine itself is LOCAL to the UDF, ie, you can't access it from outside the UDF ... its like a LOCAL UDF ...

-Shawn

Top
#66664 - 2002-06-12 03:22 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
when I started parsing this, I took JPOLS-approach.
this kind of thinking starts from the idea of having at least one execute statement in every script/UDF.

so tried with the style of execute(baseconverter)
but it took too much letters to spell the execute-function call.
maybe should ask ruud to reduce it to exec...
also @self for picking up functions name...
_________________________
!

download KiXnet

Top
#66665 - 2002-06-12 03:34 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I thought of converting to base 2 instead of base 10 right off the bat... Base 2 is fairly easy to convert to. It's a lot simpler to convert FROM base 2 than using the MOD function, as well.

Brian

Top
#66666 - 2002-06-12 03:42 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
don't know. I thought this also but then came up with thougt of conversion from base2 to base3...
it actually would be easy.
but is it easy to convert from other bases to base2...

base2-to-base3...
I understand yes...
base2-to-base7...
don't want to think anymore!
mom...

what if you make this script and we make it small [Smile]

[ 12 June 2002, 15:46: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#66667 - 2002-06-12 03:49 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I dunno.. still thinking on it.. Honestly, I don't think we're going to get much tighter code than we have.

Brian

Top
#66668 - 2002-06-12 03:58 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
brian, so it wasn't about one char [Big Grin]
_________________________
!

download KiXnet

Top
#66669 - 2002-06-12 03:59 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Ok.. now to make it usable with error checking.. any takers?.. i'm starting to work on that now..

Brian

[ 12 June 2002, 16:18: Message edited by: BrianTX ]

Top
Page 5 of 6 « First<23456>


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

Who's Online
0 registered and 239 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.078 seconds in which 0.026 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