Page 6 of 9 « First<45678>Last »
Topic Options
#178269 - 2007-07-23 10:41 PM Re: KiXgolf Freebie: Quicksum [Re: Gargoyle]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
I have so much to learn. What fun tomorrow will be.
_________________________
Every day is a school day

Top
#178270 - 2007-07-23 10:45 PM Re: KiXgolf Freebie: Quicksum [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
allen, it's a positive increment.
what I mean, if you start 1, either it counts 4 billion loops to reach zero or it does loop infinetly.
but starting from 1 can't be right away 0, as my math says 1=0 is false.

thus, a bug.
_________________________
!

download KiXnet

Top
#178274 - 2007-07-24 12:05 AM Re: KiXgolf Freebie: Quicksum [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Your understanding of math/programming is well beyond mine... no doubt about it.

I guess I could see what you mean about infinity, but I guess I would never see how it is a positive increment. 0 is less than 1 (I think anyway )

Top
#178275 - 2007-07-24 01:41 AM Re: KiXgolf Freebie: Quicksum [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, positive increment it is if I don't specify negative step, right?
so, it doesn't matter what is the final number, it will count positively.

now, you wonder why I expect it to come back to zero at some point?
that's because once it reaches 2 147 483 647, it can't add no more numbers, it's the limit.
thus, adding one more to that will result in -2 147 483 647 and -2 147 483 646 after that, until it would reach zero.

anyway, like said, it doesn't matter what is the X in "to X", kix should always keep on incrementing until it hits that value.
and as 0 is smaller than the starting number of 1, it should just keep on looping. approx. 4 294 967 294 times to be exact.
_________________________
!

download KiXnet

Top
#178276 - 2007-07-24 03:23 AM Re: KiXgolf Freebie: Quicksum [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Interesting Jooel.

Back to Golf...I'm surprised there have not been any new scores posted.

Top
#178283 - 2007-07-24 06:27 AM Re: KiXgolf Freebie: Quicksum [Re: Allen]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Looks like you guys have been enjoying the warm-up \:\)
_________________________
There are two types of vessels, submarines and targets.

Top
#178284 - 2007-07-24 08:27 AM Re: KiXgolf Freebie: Quicksum [Re: Benny69]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Interesting Code Dale,

there is no loop!??!
Will have to have a look on it... or maybe a stare

edit: I don't get it ... there is no loop but if I comment if $ I get a stack overflow error

edit some more: Oh, recursively calling itself, didn't see that


Edited by Jochen (2007-07-24 08:50 AM)
Edit Reason: Now I see
_________________________



Top
#178289 - 2007-07-24 09:32 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
Here's my 81

 Code:
Function a($b)
Dim  $, $w
For $ = 1 to 255
	$w=Asc(SubStr($b,$))-64
	if $w>0 $a=$a+$w*$

EndFunction


I've really got to get my head around these recursive function calls to see if it can be improved. You chaps have some mean tricks up your sleeves.


Edited by acmp (2007-07-24 09:47 AM)
Edit Reason: oops, mis stated $w>0
_________________________
Every day is a school day

Top
#178290 - 2007-07-24 09:42 AM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Benny's code reduced to 78

Hey Jooel - no DIM
 Code:
Function a($)
	if $
		$a=asc(right($,1))-64
		$a=a(left($,~))+len($)*$a*($a>)
EndFunction

Top
#178291 - 2007-07-24 09:43 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Jens,

am I allowed to introduce a second required parameter to the udf and change the test script to pass an additional value ?

If yes, there would be a shiny 71 score

edit: I think not as the rules clearly state that optional parameters are allowed, Jens?
_________________________



Top
#178292 - 2007-07-24 09:45 AM Re: KiXgolf Freebie: Quicksum [Re: Richard H.]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Neat trick there Richard.
_________________________



Top
#178293 - 2007-07-24 10:10 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
Jochen,

Rule 12:
12) Parameter names of the UDF's can be changed and additional optional parameters can be added.

Go for it.
_________________________
Every day is a school day

Top
#178294 - 2007-07-24 10:12 AM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Well optional is the culprit here.

optional scores 8 so the improvement would be negative (84).
If required would be possible....
_________________________



Top
#178295 - 2007-07-24 10:16 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Anyway, just for the records:

 Code:
Function a($,optional $b)
    $b = $b + 1
    if $
        $a=a(right($,~),$b)+$b*(asc($)-64)*($>!)
EndFunction


scores 84
_________________________



Top
#178297 - 2007-07-24 10:28 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
Jochen,
What is the $>! doing?

And, is there anywhere where these tricks are documented?
_________________________
Every day is a school day

Top
#178300 - 2007-07-24 10:39 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok,

reworked my own code for a nice 78 score

 Code:
function a($)
    dim $i
    for $i = 1 to 255
        $a = $a + $i * (asc($)-64) * ($>!)
        $ = right($,~)
endfunction


Running Test 1...Done
Running Test 2...Done
Running Test 3...Done
Running Test 4...Done
Running Test 5...Done
Running Test 6...Done
Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = KIXGOL~1.KIX

Computer
OS = Windows 2000 Professional
CPU = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed = 2793 MHz
Memory = 504 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/24 10:39:21.640
Processing End = 2007/07/24 10:39:21.656
Duration = 0000/00/00 00:00:00.016
KiXGolf Score = 78

Thank you for participating in KiXtart Golf!
_________________________



Top
#178301 - 2007-07-24 10:46 AM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yo,

the ($>!) is just validating if the character $ starts with has a higher 'value' than ! (Not every string needs quotes). So if $ starts with a space character the expression results in 0 (! = ascii 33, space = 32), and if it starts with a Letter it results in 1

This feature can be utilized for eg. sorting functions...
_________________________



Top
#178302 - 2007-07-24 10:52 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
This feels a bit like cheating, but hey, it's a 77

 Code:
function a($)
    dim $i
    for $i = 1 to 99
        $a = $a + $i * (asc($)-64) * ($>!)
        $ = right($,~)
endfunction

Running Test 1...Done
Running Test 2...Done
Running Test 3...Done
Running Test 4...Done
Running Test 5...Done
Running Test 6...Done
Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = KIXGOL~1.KIX

Computer
OS = Windows 2000 Professional
CPU = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed = 2793 MHz
Memory = 504 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/24 10:52:16.140
Processing End = 2007/07/24 10:52:16.156
Duration = 0000/00/00 00:00:00.016
KiXGolf Score = 77

Thank you for participating in KiXtart Golf!
_________________________



Top
#178303 - 2007-07-24 10:52 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
Thanks for explaining, I substituted the ! for 0 and found it still worked so I was assuming it was something like that.

 Code:
for $i = 1 to 255

glad I could help ;\)
_________________________
Every day is a school day

Top
#178304 - 2007-07-24 10:55 AM Re: KiXgolf Freebie: Quicksum [Re: acmp]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
'coz it is cheating!
_________________________
Every day is a school day

Top
Page 6 of 9 « First<45678>Last »


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

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

Generated in 0.086 seconds in which 0.031 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