Sealeopard
(KiX Master)
2007-07-23 01:57 AM
KiXgolf Freebie: Quicksum

=============
The Challenge: Quicksum
=============


A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data.

For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces.

A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26.

Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL":
 Code:
        ACM: 1*1  + 2*3 + 3*13 = 46

MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650



A download is available at http://s91376351.onlinehome.us/kixtart/KiXgolf_Quicksum.zip

=============
Inputs & Outputs
=============


Input: A packet containing 1 to 255 characters

Output: An integer denoting the Quicksum of the input packet

=======
Scoring
=======


The solution must pass all tests in order for it's KiXgolf Score to be considered.

When posting KiXtart Golf Scores, please include the KIXGOLF_*.TXT file that is created in the script directory. It contains some basic information about the computer that the script is run on and the resulting scores.

============
Test program
============


Test cases are provided to help screen entries and to provide the Golf Score.
Any script that passes the test cases can be submitted. If you are surprised that your solution passed the test cases, please submit it anyway! That will help me identify bugs in the test program.

================================================================
KiXtart GOLF - How To Play
================================================================


Most importantly, anybody can play, no age restrictions, no penalties, no handicap!

The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.

Example: How many positive elements are in array $a?

Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9]

One approach:
 Code:
for $b=0 to ubound($a)
  if $a[$b]>0
    $c=$c+1
  endif
next

for a score of 45.

Another solution is:
 Code:
DO
  $b=$b+1
  if $a[$b]>0
    $c=$c+1
  endif
UNTIL $b>(UBOUND($a)+1)

for a score of 53.

Better approach: Code sample 1

================================================================
KiXtart GOLF - The Rules
================================================================


1) The goal of KiXtart Golf is to score the lowest strokes.
2) Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count or spaces in between the '=' sign when assigning variables, e.g. '$a = $b' scores 5.
3) Code can be constructed any way you like, as long as it does not generate syntax or other errors when running the script in KiXtart.
4) The final solution MUST pass all test scripts that accompagny the KiXtart golf challenge. Some test scripts may not be included in the publicly available test suite but may be utilized as part of the official KiXgolf score verification.
7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player.
8) During the public coding phase, code should be posted, reused, and borrowed from other players.
9) The test script contains the official KiXgolf scoring engine
10) Only the person posting a particular score will be recognized for the score, unless the KiXtart Golf Challenge organizer or another delegate posts code on behalf of a player
11) KiXtart Golf (a.k.a KiXgolf) codes must be written inside the KiXgolf UDF collection tags, ';!' and ';!;!'
12) Parameter names of the UDF's can be changed and additional optional parameters can be added.
13) Additional helper UDFs can be written as long as they reside inside the ';!' and ';!;!' tags.
14) The use of '$' as a variable is allowed.
15) The UDF layout is up to coder.
16) The UDF is expected to finish in a reasonable time, that is, on modern computers inside 1 hour timeframe.
17) You can submit scores as often as you want.
18) If you reach leading score, you are obligated to post your score immediately so others can try to compete with you.
19) The UDF may only use the KiXtart/KiXforms commands/functions/macros, no other code fragments are allowed.
20) Calls to COM components that are part of a standard default Windows installation are allowed.
21) The use of the KiXforms DLL is also permitted as the KiXforms DLL can now be considered an integral part of KiXtart scripting.
22) Calls to other executables, as long as they are part of a standard default Windows installation are allowed.
23) The UDF should be self-contained (except for any I/O mentioned in the challenge). In particular, you may not do things like fetching extra data from a remote site or file.
24) You may assume ASCII as character set.
25) You may use block comments as the KiXgolf Scoring Engine now supports block comments.
26) You are allowed to only use publicly available versions of KiXtart and KiXforms, private builds or alpha builds are NOT allowed.
27) Your submitted score must include the result print of the KiXgolf test-engine.
28) The SETOPTION() parameters in the KiXgolf script may not be modified and will govern the script behavior. SETOPTION() parameters may change depending on the particular needs of the KiXgolf challenge.
29) Tokenizing the UDF, script, or portions thereof is not allowed.
30) If something is not explicitly denied by the rules, it's allowed.
31) If Confusion arises, arranger of the KiXgolf round has the final say.


================================================================
KiXtart GOLF - The Duration of the Competition
================================================================


Open ended combined private/public round. There's no private coding round per se but you can definitley hold off posting your code solutions until a couple of other participants have posted KiXgolf scores

A download is available at http://s91376351.onlinehome.us/kixtart/KiXgolf_Quicksum.zip


AllenAdministrator
(KiX Supporter)
2007-07-23 06:54 AM
Re: KiXgolf Freebie: Quicksum

Jens...

What's the point of the vartype check here:

if $iOutput=$iResult and vartype($iResult)=2

My results are failing because the vartype=3

For example:

 Quote:

Running Test 1...
Expecting 46
Recieved 46
Vartype 3
Done

Running Test 2...
Expecting 650
Recieved 650
Vartype 3
Done

Running Test 3...
Expecting 4690
Recieved 4690
Vartype 3
Done

Running Test 4...
Expecting 75
Recieved 75
Vartype 3
Done

Running Test 5...
Expecting 434
Recieved 434
Vartype 3
Done

Running Test 6...
Expecting 1960
Recieved 1960
Vartype 3
Done

Your solution failed 6 of 6 tests.


AllenAdministrator
(KiX Supporter)
2007-07-23 07:19 AM
Re: KiXgolf Freebie: Quicksum

If my results are correct...

KiXGolf Score = 89


AllenAdministrator
(KiX Supporter)
2007-07-23 07:40 AM
Re: KiXgolf Freebie: Quicksum

KiXGolf Score = 85

JochenAdministrator
(KiX Supporter)
2007-07-23 09:14 AM
Re: KiXgolf Freebie: Quicksum

Jens,

I don't think that we are able to produce Vartype 2 results (integer),
You should change the verification to vartype = 3 (long integer) ;\)

btw. first result :

 Code:

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 failed 6 of 6 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/23 09:14:26.343
Processing End   = 2007/07/23 09:14:26.359
Duration         = 0000/00/00 00:00:00.015
KiXGolf Score    = 128

Thank you for participating in KiXtart Golf!


JochenAdministrator
(KiX Supporter)
2007-07-23 09:17 AM
Re: KiXgolf Freebie: Quicksum

KixGolf Score = 114

JochenAdministrator
(KiX Supporter)
2007-07-23 09:26 AM
Re: KiXgolf Freebie: Quicksum

109

JochenAdministrator
(KiX Supporter)
2007-07-23 09:36 AM
Re: KiXgolf Freebie: Quicksum

And ..... 97

JochenAdministrator
(KiX Supporter)
2007-07-23 09:38 AM
Re: KiXgolf Freebie: Quicksum

93

Still some strokes left to catch Allen


JochenAdministrator
(KiX Supporter)
2007-07-23 09:41 AM
Re: KiXgolf Freebie: Quicksum

91

JochenAdministrator
(KiX Supporter)
2007-07-23 09:47 AM
Re: KiXgolf Freebie: Quicksum

90

Nice simple challenge \:\)


JochenAdministrator
(KiX Supporter)
2007-07-23 10:16 AM
Re: KiXgolf Freebie: Quicksum

87

Richard H.Administrator
(KiX Supporter)
2007-07-23 10:32 AM
Re: KiXgolf Freebie: Quicksum

87

JochenAdministrator
(KiX Supporter)
2007-07-23 10:35 AM
Re: KiXgolf Freebie: Quicksum

85

Now I should have the same as Allan


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 11:49 AM
Re: KiXgolf Freebie: Quicksum

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 12:50:07.203
Processing End = 2007/07/23 12:50:07.218
Duration = 0000/00/00 00:00:00.014
KiXGolf Score = 88


JochenAdministrator
(KiX Supporter)
2007-07-23 11:50 AM
Re: KiXgolf Freebie: Quicksum

Uh Oh...

can we expect a score less than ours?


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 11:51 AM
Re: KiXgolf Freebie: Quicksum

KiXGolf Score = 87

Arend_
(MM club member)
2007-07-23 12:21 PM
Re: KiXgolf Freebie: Quicksum

KixGolf Score = 145 :P

Witto
(MM club member)
2007-07-23 12:35 PM
Re: KiXgolf Freebie: Quicksum

Great, KiXgolf
Shouldn't the rules be modified to the game?
 Originally Posted By: sealeopard

7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player.

 Originally Posted By: sealeopard

There's no private coding round per se but you can definitley hold off posting your code solutions until a couple of other participants have posted KiXgolf scores

  • I presume the INPUT strings in the INI file are always uppercase?
  • I presume I can rename the function name and parameters in kixgolf_qs.udf?
  • I also changed
    If $iOutput=$iResult And VarType($iResult)=2
    to
    If $iOutput=$iResult And VarType($iResult)=3

 Code:
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   = kixgolf_qs.kix

Computer
OS               = Windows XP Professional
CPU              = Intel Pentium Model 15
Speed            = 1995 MHz
Memory           = 2040 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.3

KiXtart Golf Score
Tournament       = Quicksum
Processing Start = 2007/07/23 12:33:25.817
Processing End   = 2007/07/23 12:33:25.817
Duration         = 0000/00/00 00:00:00.000
KiXGolf Score    = 93

Thank you for participating in KiXtart Golf!


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 12:54 PM
Re: KiXgolf Freebie: Quicksum

lol.
already got 3 totally different codes at 87 :P


JochenAdministrator
(KiX Supporter)
2007-07-23 01:02 PM
Re: KiXgolf Freebie: Quicksum

Oh yeah,

not posted official result yet.
This result was with modified kixgolf_qs.kix in line 69 to:
if $iOutput=$iResult and vartype($iResult)=3

 Code:
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/23 13:02:05.171
Processing End   = 2007/07/23 13:02:05.187
Duration         = 0000/00/00 00:00:00.015
KiXGolf Score    = 85

Thank you for participating in KiXtart Golf!


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 01:07 PM
Re: KiXgolf Freebie: Quicksum

k, now I have 2 saved versions of 85.

Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_qs.kix

Computer
OS = Windows XP Professional
CPU = Intel Pentium Model 13
Speed = 1861 MHz
Memory = 1014 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 14:08:21.015
Processing End = 2007/07/23 14:08:21.031
Duration = 0000/00/00 00:00:00.016
KiXGolf Score = 85


Witto
(MM club member)
2007-07-23 01:08 PM
Re: KiXgolf Freebie: Quicksum

In contradiction to the rules, I understand there is no private coding phase and it is allowed to post code, isn't it?

JochenAdministrator
(KiX Supporter)
2007-07-23 01:09 PM
Re: KiXgolf Freebie: Quicksum

Yeah I think so.

This is just a warmup \:\)


Witto
(MM club member)
2007-07-23 01:12 PM
Re: KiXgolf Freebie: Quicksum

Can't wait to post... I just do not see shorter ways.

Witto
(MM club member)
2007-07-23 01:16 PM
Re: KiXgolf Freebie: Quicksum

Is it allowed to change
Function a($)
to i.e.
Function a($b)
?


Sealeopard
(KiX Master)
2007-07-23 01:22 PM
Re: KiXgolf Freebie: Quicksum

Will make appropriate correction for the VARTYPE() test.
Yes, the variable names inside the UDF can be changed, rule #12.


Witto
(MM club member)
2007-07-23 01:29 PM
Re: KiXgolf Freebie: Quicksum

Here is my code good for a KiXGolf Score of 93
 Code:
Function a($b)
	Dim $, $c
	For $ = 0 to Len($b)
		$c = Asc(SubStr($b,$,1))-64
		$a = IIf($c<0,0,$c)*$ + $a
EndFunction


JochenAdministrator
(KiX Supporter)
2007-07-23 01:41 PM
Re: KiXgolf Freebie: Quicksum

mine and probably Allans and Jooels 85:

 Code:
Function a($i)
    dim $, $_
    for $ = 1 to len($i)
        $_ = asc(substr($i,$))-64
        if $_ > 0
            $a = $a + $ * $_
;        endif
;    next
EndFunction 


JochenAdministrator
(KiX Supporter)
2007-07-23 01:48 PM
Re: KiXgolf Freebie: Quicksum

Witto,

here is yours for a score of 91

 Code:
Function a($b)
	Dim $, $c
	For $ = 0 to Len($b)
		$c = Asc(SubStr($b,$))-64
		$a = IIf($c<0,0,$c)*$ + $a
EndFunction


Witto
(MM club member)
2007-07-23 02:35 PM
Re: KiXgolf Freebie: Quicksum

Could have guessed that Asc() only evaluates the first character in a string.

JochenAdministrator
(KiX Supporter)
2007-07-23 02:35 PM
Re: KiXgolf Freebie: Quicksum



Arend_
(MM club member)
2007-07-23 02:39 PM
Re: KiXgolf Freebie: Quicksum

Here's mine for a score of 121
 Code:
Function a($)
  Dim $x, $y
  $x = 1
  While $x <= Len($)
    $y = Asc(SubStr($,$x,1))
    If $y>64 AND $y<91 $a=$a+($x*($y-64)) EndIf
    $x=$x+1
  Loop
EndFunction


Witto
(MM club member)
2007-07-23 02:41 PM
Re: KiXgolf Freebie: Quicksum

At first glance: drop the loop at the end

Witto
(MM club member)
2007-07-23 02:52 PM
Re: KiXgolf Freebie: Quicksum

  • Replace the
     Code:
      $x = 1
      While $x <= Len($)
    ...
        $x=$x+1
      Loop
    

    by
     Code:
      For $x = 1 to Len($)
    ...
      ;Next
    
  • Name your most used variable $


Arend_
(MM club member)
2007-07-23 02:53 PM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: Witto
At first glance: drop the loop at the end

Thx for the suggestions but ehm, I don't mean to be ingratefull or anything it was just my 2nd attempt overall, haven't had the time yet to optimize since I am at work. This was just getting it working \:\)


JochenAdministrator
(KiX Supporter)
2007-07-23 02:56 PM
Re: KiXgolf Freebie: Quicksum

The loop at the end, the 3rd parameter of asc(), two parentheses, starting with null placing the increment at the top saves us the endif,
results in 121 - 25 = 96

 Code:
Function a($)
  Dim $x, $y
  While $x <= Len($)
    $x=$x+1
    $y = Asc(SubStr($,$x))
    If $y>64
        $a=$a+$x*($y-64)
;    EndIf
;  Loop
EndFunction


Arend_
(MM club member)
2007-07-23 02:59 PM
Re: KiXgolf Freebie: Quicksum

Anyway with Witto's suggestions 110:
Edit: Witto's suggestions failed the tests.
Here are Some of witto's and some of Jochen's suggestions put together for a score of 117
 Code:
Function a($)
  Dim $x, $y
  $x = 1
  While $x <= Len($)
    $y = Asc(SubStr($,$x))
    If $y>64 $a=$a+($x*($y-64)) EndIf
    $x=$x+1
EndFunction


Witto
(MM club member)
2007-07-23 03:05 PM
Re: KiXgolf Freebie: Quicksum

the For/Next makes the $=$+1 redundant
Because of that, you can drop the preceeding EndIf


Arend_
(MM club member)
2007-07-23 03:07 PM
Re: KiXgolf Freebie: Quicksum

edited my last post

JochenAdministrator
(KiX Supporter)
2007-07-23 03:07 PM
Re: KiXgolf Freebie: Quicksum

Arend,

-no need to increment $
-the parentheses surrounding the multiplication are superflous as the priority rule of multiplication before addition is valid here too
-AND $y<91 can also be ommitted


Arend_
(MM club member)
2007-07-23 03:08 PM
Re: KiXgolf Freebie: Quicksum

91:
 Code:
Function a($)
  Dim $x, $y
  For $x = 0 to Len($)
    $y = Asc(SubStr($,$x))
    If $y>64 $a=$a+($x*($y-64))
EndFunction


Arend_
(MM club member)
2007-07-23 03:12 PM
Re: KiXgolf Freebie: Quicksum

90:
 Code:
Function a($b)
  Dim $, $y
  For $ = 0 to Len($b)
    $y = Asc(SubStr($b,$))
    If $y>64 $a=$a+($*($y-64))
EndFunction

Presumably final code, basically not mine anymore but Witto's and Jochen's code.


Witto
(MM club member)
2007-07-23 03:16 PM
Re: KiXgolf Freebie: Quicksum

Now you have twice 64 in your code
substract it directly here
$y = Asc(SubStr($b,$))-64
Now evaluate for > 0
If $y>0 $a=$a+($*$y)


Arend_
(MM club member)
2007-07-23 03:18 PM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: Witto
Now you have twice 64 in your code
substract it directly here
$y = Asc(SubStr($b,$))-64
Now evaluate for > 0
If $y>0 $a=$a+($*$y)

that makes 87:
 Code:
Function a($b)
  Dim $, $y
  For $ = 0 to Len($b)
    $y = Asc(SubStr($b,$))-64
    If $y>0 $a=$a+($*$y)
EndFunction


JochenAdministrator
(KiX Supporter)
2007-07-23 03:21 PM
Re: KiXgolf Freebie: Quicksum

I don't see why you still insist on parenthesing your multiplications ;\)

Witto
(MM club member)
2007-07-23 03:21 PM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: apronk
Presumably final code, basically not mine anymore but Witto's and Jochen's code.

Don't think so. The solutions are very resembling.
I think it is a good exercise to see how we think and to get to know the little tricks that can golf the score


Arend_
(MM club member)
2007-07-23 03:24 PM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: Jochen
I don't see why you still insist on parenthesing your multiplications ;\)

True, not needed anymore
85:
 Code:
Function a($b)
  Dim $, $y
  For $=0 to Len($b)
    $y=Asc(SubStr($b,$))-64
    If $y>0 $a=$a+$*$y
EndFunction


Witto: You are right, this was my first KixGolf participation \:\)


Witto
(MM club member)
2007-07-23 03:26 PM
Re: KiXgolf Freebie: Quicksum

That gives you at least 1 point for participating \:D

Richard H.Administrator
(KiX Supporter)
2007-07-23 03:35 PM
Re: KiXgolf Freebie: Quicksum

My slightly different approach. More shots (86), but I get to see more of the unusual scenery ;\)

 Code:
Function a($)
	Dim $i,$s
	While $
		$i=$i+1
		$s=Asc($)-64
		$=SubStr($,2)
		$a=$a+$i*$s*($s>)
EndFunction


acmp
(Getting the hang of it)
2007-07-23 03:56 PM
Re: KiXgolf Freebie: Quicksum

I've got a respectable 99 for my first ever go at kixgolf. I'm happy.

when do we post code?

[edit]
Oop's just refereshed the list and saw all the code.


acmp
(Getting the hang of it)
2007-07-23 04:03 PM
Re: KiXgolf Freebie: Quicksum

Just reviewed some code and got down to 90

Is it really ok to not close If's and other loops?

Any way, my code is:
 Code:
Function a($)
dim  $q, $w
for $q = 1 to len($)
	$w=asc(substr($,$q,1))-64
	if $w>0 $a=$a+($w*$q)
endfunction


Witto
(MM club member)
2007-07-23 04:09 PM
Re: KiXgolf Freebie: Quicksum

that looks like the code Jochen posted.
$a+$w*$q is the same as $a+($w*$q)
Maybe you can replace $q or $q by $.


AllenAdministrator
(KiX Supporter)
2007-07-23 04:14 PM
Re: KiXgolf Freebie: Quicksum

Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_qs.KIX

Computer
OS = Windows Vista Business Edition
CPU = AMD Athlon(tm) 64 X2 Dual Core Processor 5000+
Speed = 2604 MHz
Memory = 2048 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 10:17:54.661
Processing End = 2007/07/23 10:17:54.677
Duration = 0000/00/00 00:00:00.016
KiXGolf Score = 83

Thank you for participating in KiXtart Golf!


acmp
(Getting the hang of it)
2007-07-23 04:31 PM
Re: KiXgolf Freebie: Quicksum

Good score Allen,

any clues?


acmp
(Getting the hang of it)
2007-07-23 04:37 PM
Re: KiXgolf Freebie: Quicksum

After a clarification,

Is
 Code:
function a($b)

legal?

I didn't think you could edit the base code. So, I'm at 86, or 85 if I cheat.


AllenAdministrator
(KiX Supporter)
2007-07-23 04:39 PM
Re: KiXgolf Freebie: Quicksum

I'm waiting on a few others to post scores yet... ;\)

Here's a hint acmp. ()


acmp
(Getting the hang of it)
2007-07-23 04:50 PM
Re: KiXgolf Freebie: Quicksum

Had a genius moment:


Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_qs.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.00GHz
Speed = 2992 MHz
Memory = 1022 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 15:52:58.464
Processing End = 2007/07/23 15:52:58.510
Duration = 0000/00/00 00:00:00.046
KiXGolf Score = 83

Thank you for participating in KiXtart Golf!
Could be 82 with the cheat!


JochenAdministrator
(KiX Supporter)
2007-07-23 04:54 PM
Re: KiXgolf Freebie: Quicksum

Very Nice Richard,

here is a 85 based on yours ;\)

 Code:
Function a($)
	Dim $i,$s
	While $
		$i=$i+1
		$s=Asc($)-64
		$=Right($,~)
		$a=$a+$i*$s*($s>)
EndFunction


AllenAdministrator
(KiX Supporter)
2007-07-23 05:00 PM
Re: KiXgolf Freebie: Quicksum

wait a minute... I didn't give you that good of a hint... hmmmm must be more to find

JochenAdministrator
(KiX Supporter)
2007-07-23 05:00 PM
Re: KiXgolf Freebie: Quicksum

woot

how did you squeeze out 2(3) more strokes ???


acmp
(Getting the hang of it)
2007-07-23 05:09 PM
Re: KiXgolf Freebie: Quicksum

Now I have good code I'm not too keen to post either.

I removed my () from the math's bit as they were unnecessary. Then the light bulb went on and I shaved another 3 chars.


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 05:14 PM
Re: KiXgolf Freebie: Quicksum

hmm...
83 sounds weird.

need to do some testing. my split(join()) udf will never get there though... it's totally stuck at 85


acmp
(Getting the hang of it)
2007-07-23 05:17 PM
Re: KiXgolf Freebie: Quicksum

Here we go...


Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_qs.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.00GHz
Speed = 2992 MHz
Memory = 1022 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 16:16:49.784
Processing End = 2007/07/23 16:16:49.799
Duration = 0000/00/00 00:00:00.014
KiXGolf Score = 81


Witto
(MM club member)
2007-07-23 05:19 PM
Re: KiXgolf Freebie: Quicksum

Using
Function a($b)
is no cheat
See rule 12


acmp
(Getting the hang of it)
2007-07-23 05:21 PM
Re: KiXgolf Freebie: Quicksum

yep, just checked and updated. I'm getting into this.

Witto
(MM club member)
2007-07-23 05:21 PM
Re: KiXgolf Freebie: Quicksum

also score 85
 Code:
Function a($b)
	Dim $, $c
	For $ = 0 to Len($b)
		$c = Asc(SubStr($b,$))-64
		$a = $a + $c * $ * ($c>)
EndFunction


JochenAdministrator
(KiX Supporter)
2007-07-23 05:26 PM
Re: KiXgolf Freebie: Quicksum

Yep.

had this as well included into mine ...


JochenAdministrator
(KiX Supporter)
2007-07-23 05:29 PM
Re: KiXgolf Freebie: Quicksum

This is a complete different approach, isn't it ?

Howard Bullock
(KiX Supporter)
2007-07-23 05:36 PM
Re: KiXgolf Freebie: Quicksum

$a = 1
? "vartype = " + vartype(cint($a))
? "vartype = " + vartypename(cint($a))

$a = int($a)
? "vartype = " + vartype($a)
? "vartype = " + vartypename($a)


Produces a Long (vartype=3). Is this a Kix4.52 bug?


AllenAdministrator
(KiX Supporter)
2007-07-23 05:58 PM
Re: KiXgolf Freebie: Quicksum

Sadly, I've got to do some real work \:\(

With the variable mod my score is 82. Catch you guys later tonight.


Benny69
(MM club member)
2007-07-23 06:59 PM
Re: KiXgolf Freebie: Quicksum

ok, i can't let you guys have all the fun (83):

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.51
KiXGolf Script = kixgolf_qs.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) D CPU 3.20GHz
Speed = 3200 MHz
Memory = 2048 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 11:58:05.262
Processing End = 2007/07/23 11:58:05.277
Duration = 0000/00/00 00:00:00.014
KiXGolf Score = 83

Thank you for participating in KiXtart Golf!
Press any key to continue...


Benny69
(MM club member)
2007-07-23 07:07 PM
Re: KiXgolf Freebie: Quicksum

and yes a different, but not completely different approach

JochenAdministrator
(KiX Supporter)
2007-07-23 08:37 PM
Re: KiXgolf Freebie: Quicksum

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 XP Professional
CPU = Intel Pentium Model 15
Speed = 2400 MHz
Memory = 2048 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 20:47:28.656
Processing End = 2007/07/23 20:47:28.656
Duration = 0000/00/00 00:00:00.000
KiXGolf Score = 81

Thank you for participating in KiXtart Golf!


Benny69
(MM club member)
2007-07-23 08:44 PM
Re: KiXgolf Freebie: Quicksum

you dawg!

JochenAdministrator
(KiX Supporter)
2007-07-23 08:48 PM
Re: KiXgolf Freebie: Quicksum

hehe ... updated above with a better runtime (did some processor intensive stuff during last run)

LonkeroAdministrator
(KiX Master Guru)
2007-07-23 09:04 PM
Re: KiXgolf Freebie: Quicksum

don't think it's a bug as it was reported years ago...
can't remember the answers or anything but remember playing with it.
kix has never (at least not in kix2001 nor in kix2010) had vartype 2.


Howard Bullock
(KiX Supporter)
2007-07-23 09:10 PM
Re: KiXgolf Freebie: Quicksum

It seems very strange to have a CINT function that does not create an integer.
 Quote:
CINT
Action
Returns an expression that has been converted to a Variant of subtype Integer.

Syntax
CINT (expression)

Parameter
Expression
Any valid expression.

Returns
Variant of subtype Integer.

Remarks
CInt differs from the Fix and Int functions, which truncate, rather than round, the fractional part of a number. When the fractional part is exactly 0.5, the CInt function always rounds it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2.


Benny69
(MM club member)
2007-07-23 09:14 PM
Re: KiXgolf Freebie: Quicksum

ok here is my 83:

 Code:
;!
Function a($)

	dim $b
	if $
		$b=asc(right($,1))-64
		$a=a(left($,~))+len($)*$b*($b>)

EndFunction
;!
;!
; end Quicksum


AllenAdministrator
(KiX Supporter)
2007-07-23 09:24 PM
Re: KiXgolf Freebie: Quicksum

Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_qs.KIX

Computer
OS = Windows Vista Business Edition
CPU = AMD Athlon(tm) 64 X2 Dual Core Processor 5000+
Speed = 2604 MHz
Memory = 2048 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 15:22:21.179
Processing End = 2007/07/23 15:22:21.194
Duration = 0000/00/00 00:00:00.015
KiXGolf Score = 82

and 81 with variable mod.


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 09:25 PM
Re: KiXgolf Freebie: Quicksum

HEHEE!!!
 Quote:

Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_qs.kix

Computer
OS = Windows XP Professional
CPU = Intel Pentium Model 13
Speed = 1861 MHz
Memory = 1014 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/07/23 22:26:29.765
Processing End = 2007/07/23 22:26:29.781
Duration = 0000/00/00 00:00:00.016
KiXGolf Score = 79


acmp
(Getting the hang of it)
2007-07-23 09:26 PM
Re: KiXgolf Freebie: Quicksum

Benny69, I have no idea why that works

What is going on?

I guess the left($,~) is some sort of walk through the string...

But I just can't see how this works. Any chance of an explination?


AllenAdministrator
(KiX Supporter)
2007-07-23 09:26 PM
Re: KiXgolf Freebie: Quicksum

I still think we can get below 80...

[edit/rant: I knew it! Dang it Jooel!!! [/rant]


acmp
(Getting the hang of it)
2007-07-23 09:30 PM
Re: KiXgolf Freebie: Quicksum

... Looking forward to it

but I'll have to go soon (back tomorrow). What happens now? how long does this section continue and when do I need to post code for validation?

sorry for ht enewbie quesitons, but I'm a newbie at kixgolf ;\)


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 09:30 PM
Re: KiXgolf Freebie: Quicksum

btw, just to show different type of code...
 Code:
Function a($b)
dim $
for $=1 to len($b)
 $a=$a+$*split(asc(substr($b,$))-64,"-")[0]
EndFunction


I still hope someone can get rid of the dim totally.
doesn't look nice ;\)

anyways, this array way was 85.


Benny69
(MM club member)
2007-07-23 09:35 PM
Re: KiXgolf Freebie: Quicksum

acmp,
left($,~) chops off the right most chr so ACM becomes AC, then it is sent back into the loop and then i am calling the function to create the count down a(left($,~))


acmp
(Getting the hang of it)
2007-07-23 09:41 PM
Re: KiXgolf Freebie: Quicksum

Thanks Benny69

AllenAdministrator
(KiX Supporter)
2007-07-23 09:45 PM
Re: KiXgolf Freebie: Quicksum

$a=$a+$*split(asc(substr($b,$))-64,"-")[0]

Jooel... you are one smart basta! Seeing this... I know 79 can be beat too.... just got to figure it out before you do!


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 09:46 PM
Re: KiXgolf Freebie: Quicksum

~ is not operator or something.
figured in some previous kixgolf tournament that one can use it as -1 in some cases.

that is, if your parameter has nothing else, NOT-inversion from nothing becomes true, which translates to -1.

and that's 1 stroke shorter than saying left($,-1) \:\)


Gargoyle
(MM club member)
2007-07-23 09:47 PM
Re: KiXgolf Freebie: Quicksum

Jeez Don't log in for a day and look what happens... If work ever slows down I might get to try...

LonkeroAdministrator
(KiX Master Guru)
2007-07-23 09:54 PM
Re: KiXgolf Freebie: Quicksum

k, if someone shortens my 79, be my guest.
I can't keep on thinking about this, otherwise my sudoku time gets shrinked too much.

 Code:
Function a($)
dim $b
while $
 $b=$b+1
 $a=$a+$b*(asc($)-64)*($>#)
 $=right($,~)
EndFunction


AllenAdministrator
(KiX Supporter)
2007-07-23 09:57 PM
Re: KiXgolf Freebie: Quicksum

Jooel... Here is your 85 down to 83/82

 Code:
Function a($)
dim $b
for $b=1 to 0^$
 $a=$a+$b*split(asc(substr($,$b))-64,"-")[0]
EndFunction


AllenAdministrator
(KiX Supporter)
2007-07-23 09:57 PM
Re: KiXgolf Freebie: Quicksum

And here is my 82/81

 Code:
Function a($)
  dim $b
  if $
    $b=asc(right($,1))-64
    $a=a(left($,~))+($b>)*$b*(0^$)
  ;endif
EndFunction


Benny69
(MM club member)
2007-07-23 10:03 PM
Re: KiXgolf Freebie: Quicksum

wow Allen, ours is very similar

AllenAdministrator
(KiX Supporter)
2007-07-23 10:05 PM
Re: KiXgolf Freebie: Quicksum

ugghhh....Must pull away from computer... must work.... (dang golf!)

Benny69
(MM club member)
2007-07-23 10:07 PM
Re: KiXgolf Freebie: Quicksum

here is 81:
 Code:
Function a($)

  dim $b
  if $
    $b=asc(right($,1))-64
    $a=a(left($,~))+($b>)*$b*($^)
		
EndFunction


AllenAdministrator
(KiX Supporter)
2007-07-23 10:11 PM
Re: KiXgolf Freebie: Quicksum

nice... I never thought of that...

here is my other entry with your genius:

83/82
 Code:
Function a($)
  dim $i,$b
  for $i=1 to $^
    $b=asc(substr($,$i))-64
    if $b>0
      $a=$a+$i*$b
    ;endif
  ;next
EndFunction


JochenAdministrator
(KiX Supporter)
2007-07-23 10:12 PM
Re: KiXgolf Freebie: Quicksum

Wonder why nobody has thought of this yet ....

Here's my 81

 Code:
Function a($i)
    dim $, $_
    for $ = 1 to 255
        $_ = asc(substr($i,$))-64
        $a = $a + $ * $_ * ($_>)
;    next
EndFunction


LonkeroAdministrator
(KiX Master Guru)
2007-07-23 10:25 PM
Re: KiXgolf Freebie: Quicksum

hey, is this a bug:
 Code:
Function a($i)
    dim $, $_
    for $ = 1 to 0
        $_ = asc(substr($i,$))-64
        $a = $a + $ * $_ * ($_>)
;    next
EndFunction


the for loop should run from 1 to upperlimit of int and then start from negative end and finally stop at 0.
but, instead, it does not go to the loop at all!?!?


AllenAdministrator
(KiX Supporter)
2007-07-23 10:27 PM
Re: KiXgolf Freebie: Quicksum

If I understand you correctly, I don't think I've ever been able to get it to increment negatively without putting a step -1.

acmp
(Getting the hang of it)
2007-07-23 10:41 PM
Re: KiXgolf Freebie: Quicksum

I have so much to learn. What fun tomorrow will be.

LonkeroAdministrator
(KiX Master Guru)
2007-07-23 10:45 PM
Re: KiXgolf Freebie: Quicksum

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.


AllenAdministrator
(KiX Supporter)
2007-07-24 12:05 AM
Re: KiXgolf Freebie: Quicksum

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 )


LonkeroAdministrator
(KiX Master Guru)
2007-07-24 01:41 AM
Re: KiXgolf Freebie: Quicksum

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.


AllenAdministrator
(KiX Supporter)
2007-07-24 03:23 AM
Re: KiXgolf Freebie: Quicksum

Interesting Jooel.

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


Sealeopard
(KiX Master)
2007-07-24 06:27 AM
Re: KiXgolf Freebie: Quicksum

Looks like you guys have been enjoying the warm-up \:\)

JochenAdministrator
(KiX Supporter)
2007-07-24 08:27 AM
Re: KiXgolf Freebie: Quicksum

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


acmp
(Getting the hang of it)
2007-07-24 09:32 AM
Re: KiXgolf Freebie: Quicksum

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.


Richard H.Administrator
(KiX Supporter)
2007-07-24 09:42 AM
Re: KiXgolf Freebie: Quicksum

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


JochenAdministrator
(KiX Supporter)
2007-07-24 09:43 AM
Re: KiXgolf Freebie: Quicksum

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?


JochenAdministrator
(KiX Supporter)
2007-07-24 09:45 AM
Re: KiXgolf Freebie: Quicksum

Neat trick there Richard.

acmp
(Getting the hang of it)
2007-07-24 10:10 AM
Re: KiXgolf Freebie: Quicksum

Jochen,

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

Go for it.


JochenAdministrator
(KiX Supporter)
2007-07-24 10:12 AM
Re: KiXgolf Freebie: Quicksum

Well optional is the culprit here.

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


JochenAdministrator
(KiX Supporter)
2007-07-24 10:16 AM
Re: KiXgolf Freebie: Quicksum

Anyway, just for the records:

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


scores 84


acmp
(Getting the hang of it)
2007-07-24 10:28 AM
Re: KiXgolf Freebie: Quicksum

Jochen,
What is the $>! doing?

And, is there anywhere where these tricks are documented?


JochenAdministrator
(KiX Supporter)
2007-07-24 10:39 AM
Re: KiXgolf Freebie: Quicksum

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!


JochenAdministrator
(KiX Supporter)
2007-07-24 10:46 AM
Re: KiXgolf Freebie: Quicksum

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


JochenAdministrator
(KiX Supporter)
2007-07-24 10:52 AM
Re: KiXgolf Freebie: Quicksum

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!


acmp
(Getting the hang of it)
2007-07-24 10:52 AM
Re: KiXgolf Freebie: Quicksum

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 ;\)


acmp
(Getting the hang of it)
2007-07-24 10:55 AM
Re: KiXgolf Freebie: Quicksum

'coz it is cheating!

JochenAdministrator
(KiX Supporter)
2007-07-24 11:00 AM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: acmp
 Code:
for $i = 1 to 255

glad I could help ;\)


Hmmm, I posted that yesterday evening ;\)


acmp
(Getting the hang of it)
2007-07-24 12:38 PM
Re: KiXgolf Freebie: Quicksum

my bad, I'll get more coffee, should help me stay on track.

I didn't notice your earlier post, I followed from your 9:16 to 9:39 (both today)

please accept my apologies.


JochenAdministrator
(KiX Supporter)
2007-07-24 12:44 PM
Re: KiXgolf Freebie: Quicksum

you're welcome

JochenAdministrator
(KiX Supporter)
2007-07-24 01:11 PM
Re: KiXgolf Freebie: Quicksum

Another 77 based on Dales' code with mods from Richard

 Code:
function a($)
  if $
    $a=asc(right($,1))-64
    $a=a(left($,~))+($a>)*$a*(0^$)
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 13:11:07.406
Processing End = 2007/07/24 13:11:07.421
Duration = 0000/00/00 00:00:00.014
KiXGolf Score = 77

Thank you for participating in KiXtart Golf!


JochenAdministrator
(KiX Supporter)
2007-07-24 01:44 PM
Re: KiXgolf Freebie: Quicksum

btw,

0^$ is a pretty clever way to say len($), Dale.
Have to keep this in mind.


Benny69
(MM club member)
2007-07-24 02:00 PM
Re: KiXgolf Freebie: Quicksum

Thanks Richard, You Da Man!
thanks, but that was Allen's, mine was ($^): 76

 Code:
;!
Function a($)
	if $
		$a=asc(right($,1))-64
		$a=a(left($,~))+($^)*$a*($a>)
EndFunction
;!
;!
; end Quicksum



JochenAdministrator
(KiX Supporter)
2007-07-24 02:06 PM
Re: KiXgolf Freebie: Quicksum

Ay Caramba !!!

Benny69
(MM club member)
2007-07-24 02:58 PM
Re: KiXgolf Freebie: Quicksum

Jochen,
if you wanted to cover all lengths, yours could be: 79

 Code:
;!
Function a($)
    dim $i
    for $i=1 to ($^)
	$a=$a+$i*(asc($)-64)*($>!)
        $=right($,~)
EndFunction
;!


AllenAdministrator
(KiX Supporter)
2007-07-24 03:11 PM
Re: KiXgolf Freebie: Quicksum

Man... go to sleep and miss all the fun.

JochenAdministrator
(KiX Supporter)
2007-07-24 03:14 PM
Re: KiXgolf Freebie: Quicksum

Well,

I have already covered all lengths with for $i = 1 to 255 (78), or could cover them with for $i = 1 to 0^$ (78 too), but i prefer to insist on my 'cheat' with for $i = 1 to 99 which scores 77


AllenAdministrator
(KiX Supporter)
2007-07-24 03:19 PM
Re: KiXgolf Freebie: Quicksum

Or 78

 Code:
Function a($)
    dim $i
    for $i=1 to 0^$
	$a=$a+$i*(asc($)-64)*($>!)
        $=right($,~)
EndFunction


JochenAdministrator
(KiX Supporter)
2007-07-24 03:23 PM
Re: KiXgolf Freebie: Quicksum

Hello?

AllenAdministrator
(KiX Supporter)
2007-07-24 03:27 PM
Re: KiXgolf Freebie: Quicksum

You posted while I was working... man, tough crowd.

JochenAdministrator
(KiX Supporter)
2007-07-24 03:28 PM
Re: KiXgolf Freebie: Quicksum



Mart
(KiX Supporter)
2007-07-24 07:03 PM
Re: KiXgolf Freebie: Quicksum

Just lurking around but so far I'm impressed.

Benny69
(MM club member)
2007-07-24 07:26 PM
Re: KiXgolf Freebie: Quicksum

Mart, Witto, Gargoyle, apronk, Shawn, Doc, Drill come on guys want to see what you got, you guys going to play? I think you could bring some fresh ideas.

LonkeroAdministrator
(KiX Master Guru)
2007-07-24 10:01 PM
Re: KiXgolf Freebie: Quicksum

they are not gonna play.
they don't have a change, so they will just keep on lurkin ;\)


Mart
(KiX Supporter)
2007-07-25 12:01 AM
Re: KiXgolf Freebie: Quicksum

If there was time to play I'd give it a go but I'm just to damn busy setting up an inventory script at work so I'll be online but can't play and do the inventory stuff at the same time. Lurking a bit is possible because I can hide that as looking for ways to implement some part of the inventory script.

My CEO would like to see the inventory stuff done and does not care about KixGolf at all

Depending on the challenge maybe the next one will be my first KixGolf game.


Mart
(KiX Supporter)
2007-07-25 12:14 AM
Re: KiXgolf Freebie: Quicksum

Oh yeah, I'm also doing some painting around the house.

Sanding, filling holes and gapes, wait for filler to dry, sanding again, put on some primer, wait for primer to dry, sand once more, paint first layer of right colour paint, wait for paint to dry, do some more sanding and paint the final layer of the right colour paint.

I'm not looking for an excuse not to play but it all takes huge amounts of time you know \:\)


Witto
(MM club member)
2007-07-25 02:21 AM
Re: KiXgolf Freebie: Quicksum

Your code is beautifull, Benny. I am still looking what it exactly does. Could you elaborate on this line? I.E. what does the XOR do?
$a=a(Left($,~))+($^)*$a*($a>)


NTDOCAdministrator
(KiX Master)
2007-07-25 02:28 AM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: Benny69
Mart, Witto, Gargoyle, apronk, Shawn, Doc, Drill come on guys want to see what you got, you guys going to play? I think you could bring some fresh ideas.


Hi Benny - no don't have time to play. I'm already doing 13+ hour days at work and trying to balance work and home and KiX ;\)


AllenAdministrator
(KiX Supporter)
2007-07-25 03:24 AM
Re: KiXgolf Freebie: Quicksum

$a=a(Left($,~))+($^)*$a*($a>)

its using recursion to call itself, basically function a() is calling function a() until it runs out of letters.

the ~ is a shortcut for -1

0^$ or $^ is a shortcut for len($) ;I have no idea how/why this works, but someone figured it out in one of the last golfs

($a>) = ($a>0)


Benny69
(MM club member)
2007-07-25 03:31 AM
Re: KiXgolf Freebie: Quicksum

Thanks Allen very well put, and i think it was Jooel or Shawn that showed me that one, one of them might elaborate more clearly.

Sealeopard
(KiX Master)
2007-07-25 04:38 AM
Re: KiXgolf Freebie: Quicksum

Jochen:

Your "99" won't cut it as the specs call for support of up to 255 characters in the Inputs & Outputs section
 Code:
[b]=============
Inputs & Outputs
=============[/b]

Input: A packet containing 1 to 255 characters


acmp
(Getting the hang of it)
2007-07-25 09:10 AM
Re: KiXgolf Freebie: Quicksum

Also,

($a>) = (0|$a) = ($a|)

Not sure if it's interesting but I noticed that OR behaves the same as XOR for the len() thing. No chars saved, but never mind.


JochenAdministrator
(KiX Supporter)
2007-07-25 09:22 AM
Re: KiXgolf Freebie: Quicksum

Oh I see,

so my scores are 78 for my own and 77 for adapting Dales/Allens (?)


Gargoyle
(MM club member)
2007-07-25 09:23 AM
Re: KiXgolf Freebie: Quicksum

I would love to play - but I am in the middle of implementing our new web filtering and doing our Virtual Office project (almost 200 workers at home full time now).

Oh then there is the family - etc etc... But I will keep lurking.


JochenAdministrator
(KiX Supporter)
2007-07-25 09:25 AM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: acmp
Also,

($a>) = (0|$a) = ($a|)


Not quite:

 Code:
break on
$=-1
($|) ?
($>)
get $


returns

-1
0


acmp
(Getting the hang of it)
2007-07-25 10:48 AM
Re: KiXgolf Freebie: Quicksum

Oops, Just noticed the code I pinched was not the XOR at all it was ($>). XOR would be ($^)

so, using a text string

 Code:
break on
$="-1"
($|) ?
($^)
get $


returns

2
2


But if $ is an integer both OR and XOR return the value of the integer. Good job we're using strings.


JochenAdministrator
(KiX Supporter)
2007-07-25 11:14 AM
Re: KiXgolf Freebie: Quicksum

I'm running out of ideas how this can be solved differently... well, at least promising ideas to shorten the code \:\(

Witto
(MM club member)
2007-07-25 12:30 PM
Re: KiXgolf Freebie: Quicksum

acmp,
Shouldn't that be
$=-1
you wrote
$="-1"
You made it a string
 Code:
Break on
$=-1
($|) ?
($^)
Get $

returns
 Code:
-1
-1


acmp
(Getting the hang of it)
2007-07-25 12:43 PM
Re: KiXgolf Freebie: Quicksum

Exactly.

IF a string is provided both OR and XOR return the lenght of the string, if an integer is used the value of the integer is returned.


Witto
(MM club member)
2007-07-25 12:48 PM
Re: KiXgolf Freebie: Quicksum

OK, I see

LonkeroAdministrator
(KiX Master Guru)
2007-07-25 04:17 PM
Re: KiXgolf Freebie: Quicksum

wicked...
think the next golf round will be out of my reach.
at least it will be hard, if all of you guys participate.


JochenAdministrator
(KiX Supporter)
2007-07-25 04:27 PM
Re: KiXgolf Freebie: Quicksum

I give up.

The last thing I worked with was this 79 code (nothing really new)
Can't improve anymore...

 Code:
function a($)
    if $
        $a = a(left($,~)) + ($^) * (asc(right($,1))-64) * (trim($)=$)
endfunction


acmp
(Getting the hang of it)
2007-07-25 04:55 PM
Re: KiXgolf Freebie: Quicksum

 Code:
* (trim($)=$)

nice test.


Richard H.Administrator
(KiX Supporter)
2007-07-25 05:36 PM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: acmp
 Code:
* (trim($)=$)

nice test.


Have to be careful though - the algorithm will fail if there is a trailing space in the string


LonkeroAdministrator
(KiX Master Guru)
2007-07-25 08:21 PM
Re: KiXgolf Freebie: Quicksum

hmm...
why trim()?


LonkeroAdministrator
(KiX Master Guru)
2007-07-25 08:23 PM
Re: KiXgolf Freebie: Quicksum

forget it, stupid q.

anyhow, this would work:
 Code:
        $a = a(left($,~)) + ($^) * (asc(right($,1))-64) * (rtrim($)=$)


LonkeroAdministrator
(KiX Master Guru)
2007-07-25 08:28 PM
Re: KiXgolf Freebie: Quicksum

and this would also yield 79:
 Code:
function a($)
    if $
        $a=right($,1)
        $a = a(left($,~)) + ($^) * (asc($a)-64) * ($a>!)
endfunction


JochenAdministrator
(KiX Supporter)
2007-07-25 08:50 PM
Re: KiXgolf Freebie: Quicksum

No Jooel,

the Rules state clearly:

 Quote:

A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter.


So the trim is perfectly fitting as we are only interested in trailing spaces and know that there can be no leading one ;\)


LonkeroAdministrator
(KiX Master Guru)
2007-07-25 09:41 PM
Re: KiXgolf Freebie: Quicksum

right.
sorry.
but wasn't me who said yours didn't work...


sixdoubleo
(Starting to like KiXtart)
2007-07-26 10:22 PM
Re: KiXgolf Freebie: Quicksum

I know it looks like everybody already has this solved, but I wanted to check it out just to see how I'd do. Is there somewhere else I can get the download? The original URL is giving me a 404. Thanks!

Sealeopard
(KiX Master)
2007-07-27 04:52 AM
Re: KiXgolf Freebie: Quicksum

Try again. Seems that the last upload didn't take. I re-uploaded the ZIP file.

Richard H.Administrator
(KiX Supporter)
2007-07-27 09:29 AM
Re: KiXgolf Freebie: Quicksum

 Originally Posted By: Jochen
No Jooel,

the Rules state clearly:

 Quote:

A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter.


So the trim is perfectly fitting as we are only interested in trailing spaces and know that there can be no leading one ;\)


Oops! That was me, not Jooel.


JochenAdministrator
(KiX Supporter)
2007-07-27 09:41 AM
Re: KiXgolf Freebie: Quicksum

Ja,

I'm not resentful there, though Jooel posted a code (rtrim) that implicitly follwed your opinion by saying "this would work".



LonkeroAdministrator
(KiX Master Guru)
2007-07-28 03:50 AM
Re: KiXgolf Freebie: Quicksum

right...
but, you can't say my rtrim version doesn't work...


JochenAdministrator
(KiX Supporter)
2007-07-28 03:00 PM
Re: KiXgolf Freebie: Quicksum

I don't

Richard H.Administrator
(KiX Supporter)
2007-07-30 09:46 AM
Re: KiXgolf Freebie: Quicksum

Nor me.

BTW Jochen, where can I get one of those big blue "mother and child" ear-rings that you are modelling in your avatar?

I'm bored with the small one that I have in at the moment.


sixdoubleo
(Starting to like KiXtart)
2007-08-01 08:42 PM
Re: KiXgolf Freebie: Quicksum

Well, not knowing all the the little tricks (EndIf and Next not needed, ASC() only evaluating the first character of a string) I get a 96 on my own merits.

Where can I find a list of some of these "quirks" you guys have found?

 Code:
Function a($t)
Dim $p, $

For $p = 1 to len($t)
    $ = asc(SubStr($t,$p,1))-64
	If $ > 0
	   $a = $a + $p * $
	EndIf
Next
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.50
KiXGolf Script = kixgolf_qs.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.00GHz
Speed = 2992 MHz
Memory = 2040 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Quicksum
Processing Start = 2007/08/01 11:43:47.213
Processing End = 2007/08/01 11:43:47.213
Duration = 0000/00/00 00:00:00.000
KiXGolf Score = 96

Thank you for participating in KiXtart Golf!


Benny69
(MM club member)
2007-08-01 09:20 PM
Re: KiXgolf Freebie: Quicksum

well done,
there is no documented list of 'quirks' (not really quirks, just coding experience).


Sealeopard
(KiX Master)
2007-08-02 03:44 AM
Re: KiXgolf Freebie: Quicksum

Shouldn't we call those codign tricks a "handicap", just to keep the Golf theme going ?