Page 2 of 6 <12345>Last »
Topic Options
#66590 - 2002-06-11 12:36 AM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
HEY BOYS...

do I get extra winnings if I post the first working code?

I ran to a bug in my script and checked out HOWARDs (both) and BRIANs scripts and they truly do not work!!!

boys boys...

run some tests before posting...
_________________________
!

download KiXnet

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, don't worry.
for kixtart (base36) to base 10 gave me result of:
217678233629972129601353024554273281088391168585973760

that propably means my script ain't fully working yet, so you have time to correct yours [Smile]
_________________________
!

download KiXnet

Top
#66592 - 2002-06-11 12:43 AM Re: Round 2: KiXtart Golf Tournament Part III
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Lonkero:

The code works for me. I tested the following script under Kixtart 4.10 RC2 and it correctly spits out KIXTART:
code:
? BaseConverter("44680832201","10","36")

exit 0

FUNCTION BaseConverter($v,$f,$t)
$y = CDBL(1)
$c = ""
$n = 0
FOR $i = LEN($V) TO 1 STEP -1
$x = SUBSTR(UCASE($V),$i,1)
IF ASC($x) > 57
$x = ASC($x) - 55
ENDIF
$n = $y * $x + $n
$y = $y * $f
NEXT
WHILE $N
$a = INT($n - (INT($n/$t) * $t))
$n = ($n-$a)/$t
IF $a > 9
$a = CHR($a + 55)
ENDIF
$c = "$a$c"
LOOP
$BaseConverter = $c
ENDFUNCTION



[ 11 June 2002, 00:43: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
mm...

tested again, and I really don't know what I messed up with it...

trying some loops again.
now brians script, which failed last time, works just fine.
also seems howards script.

so sorry guys, now it was me again who was too busy shout.

sh*t. maybe this shows you how frustrated I am...
_________________________
!

download KiXnet

Top
#66594 - 2002-06-11 01:30 AM Re: Round 2: KiXtart Golf Tournament Part III
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Nice Scripts everyone [Smile]

I believe the trick in this KixGolf game is to force KiXtart to use 'big' numbers by forcing the var to be double instead of integer!

$number = $Number * CDbl(1)

Or Shawn's approach:

$number = 0. + $Number

Should we start a new Tricks-forum ? This one could also be in the FAQ section under typecasting.

The KixGolf games is a great idea, but could we have a summary of the new tricks by the submitter or the winner of the game ?

Shouldn't this lead up to a deeper understanding of the syntax in KiXtart (and hard testing of same) ?

Just a thougt about the scoring system:
Shouldn't all variables be considered as one char, then $, $a and $array would all count as one char in the script, and the the scripts
would be a lot more readable (and easyer to submit to the forum).

-Erik

Top
#66595 - 2002-06-11 01:34 AM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I've gotten it down to 252...
.. still working on it.. going to play volleyball, though.

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
I promised to make one.
here it is.
haven't checked the kixgolf score, cause here is time 03AM and my laptops battery is dead.

anyways, proudly can say, that your scripts were too complex for me to understand, and as such, I could not adapt any of your code.
neither can I yet try to improve yours because of that.

the udf:
code:
function baseconverter($x,$f,$t)

if val($f)<>10
$y=1 $x=ucase($x)
for $c=0 to len($x)-1
$d=0.+asc(substr($x,len($x)-$c,1))
if $d>64 $d=$d-55 else $d=$d-48 endif
$d=$d*$y
$e=$e+$d
$y=0.+$y*$f
next
if val($t)=10 $x=$e goto "t" endif
endif
$z=""
do
$d="" $y=0 $e=""
for $c=1 to len($x)
$d=""+$d
$d=val($d+substr($x,$c,1))
$y=$d/$t
if $y
$d=$d-$y*$t
endif
$e=$e+$y
next
if $d>9 $d=chr($d+55) endif
$z=""+$d+$z
$x=$e
$e=val($e)
until val($e)<$t and 5>len($e)
if $e>9 $e=chr($e+55) endif
$x="$e$z"
:t
$baseconverter=$x
endfunction

one thing I wonder.
when converting from 10base, the ticks return 10
and from kixtart(base36) to ten result is 0!
is there a bug or is my script truly so fast?!?!?
using kix4.10 rc2 with:
code:
"starting the function..."
$time=@ticks
baseconverter("kixtart","36","10")
$time=@ticks-$time
?
$time
get $
exit 0

cheers mates and good/night/day...
_________________________
!

download KiXnet

Top
#66597 - 2002-06-11 03:27 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, I also got your script down to 252.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66598 - 2002-06-11 03:28 AM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Can you guys post your major revisions, so we can all have a boo ?
Top
#66599 - 2002-06-11 03:59 AM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
code:
FUNCTION BaseConverter($v,$f,$t)
$y = 1.
$c = ""
$n = 0

$i = LEN($V)
Do
$x = SUBSTR(UCASE($V),$i,1)
IF $x > 9
$x = ASC($x) - 55
ENDIF
$n = $y * $x + $n
$y = $y * $f
$i = $i -1
Until $i=0

WHILE $N
$a = INT($n - (INT($n/$t) * $t))
$n = ($n-$a)/$t
IF $a > 9
$a = CHR($a + 55)
ENDIF
$c = "$a$c"
LOOP
$BaseConverter = $c
ENDFUNCTION
;!
BaseConverter('Kixtart',36,10) ?
BaseConverter('52',10,2) ?
BaseConverter('Kixtart',36,10) ?

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66600 - 2002-06-11 04:14 AM Re: Round 2: KiXtart Golf Tournament Part III
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Erik:

With regards to the scoring, it should not be changed. Part of the fun is that the scripts become harder to read since you're trying to write it as short as possible. And that's the goal, it's definitely not about readability. Actually, the similar Golf challanges in othe rprogramming languages (I've already found pages for C++, Perl, and Matlab) all have this principle in common: shorter is better.

I like the idea of a tricks recap although I wouldn't necessarily use those in my regular scripts.
_________________________
There are two types of vessels, submarines and targets.

Top
#66601 - 2002-06-11 04:57 AM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Howard.. that looks like what I did.. I did something else, too, and got the same result. I couldn't simplify it any further, though, so I'm working on something else.. One thought I had was that the number could be converted to base 2 instead of base 10. I'm not sure it would save any effort, though. Also, I was seeing if there was a way I could shorten the conversion from ascii to a number... haven't found one, yet. (I came close.. still playing with it.)

Brian

Top
#66602 - 2002-06-11 04:57 AM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
[Embarrassed] My 1st program is wrong. It drops Zeroes.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66603 - 2002-06-11 05:28 AM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
KixGolf score = 243

code:
Function BaseConverter($v,$f,$t)
$i = len($v)
$b=1.
$n=0
Do
$ = substr($v,$i,1)
if $ > 9
$ = ASC(ucase($)) - 55
endif
$n=$b*$+$n
$b=$b*$f
$i=$i-1
Until $i=0

$c=""
While $n
$ = INT($n - (INT($n/$t) * $t))
$n = ($n-$)/$t
IF $ > 9
$ = CHR($ + 55)
ENDIF
$c = "" + $ + $c
Loop
$BaseConverter = $c
Endfunction



[ 11 June 2002, 05:57: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66604 - 2002-06-11 05:33 AM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Oops! Drops zeros? hmm. so I guess that method doesn't work, eh? I'm still playing with it.. going to bed now, though.

Brian

Top
#66605 - 2002-06-11 05:35 AM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The string of characters does not include a zero so you can't do a substr to find a zero.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66606 - 2002-06-11 05:45 AM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I thought we weren't allowed to use $ as a variable? is that changed now?

Brian

[ 11 June 2002, 05:53: Message edited by: BrianTX ]

Top
#66607 - 2002-06-11 05:48 AM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I was always under the impression we could. Jens, Help! Please clarify. Thanks.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66608 - 2002-06-11 05:52 AM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
$C is initialized to "" in the middle. I moved it closer to where it was being used. This code can be executed multiple times in a script returning the proper values each time.

[ 11 June 2002, 05:54: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66609 - 2002-06-11 05:54 AM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Where is $n initialized? suppose you had a value $n already existing in a script?

Brian

Top
Page 2 of 6 <12345>Last »


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.079 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