Page 8 of 9 « First<56789>
Topic Options
#178351 - 2007-07-25 02:28 AM Re: KiXgolf Freebie: Quicksum [Re: Benny69]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
 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 ;\)

Top
#178355 - 2007-07-25 03:24 AM Re: KiXgolf Freebie: Quicksum [Re: Witto]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
$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)

Top
#178356 - 2007-07-25 03:31 AM Re: KiXgolf Freebie: Quicksum [Re: Allen]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
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.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#178357 - 2007-07-25 04:38 AM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
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
_________________________
There are two types of vessels, submarines and targets.

Top
#178361 - 2007-07-25 09:10 AM Re: KiXgolf Freebie: Quicksum [Re: Sealeopard]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
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.
_________________________
Every day is a school day

Top
#178362 - 2007-07-25 09:22 AM Re: KiXgolf Freebie: Quicksum [Re: Sealeopard]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh I see,

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



Top
#178363 - 2007-07-25 09:23 AM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
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.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#178365 - 2007-07-25 09:25 AM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 Originally Posted By: acmp
Also,

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


Not quite:

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


returns

-1
0
_________________________



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

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
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.
_________________________
Every day is a school day

Top
#178375 - 2007-07-25 11:14 AM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I'm running out of ideas how this can be solved differently... well, at least promising ideas to shorten the code \:\(
_________________________



Top
#178392 - 2007-07-25 12:30 PM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
acmp,
Shouldn't that be
$=-1
you wrote
$="-1"
You made it a string
 Code:
Break on
$=-1
($|) ?
($^)
Get $

returns
 Code:
-1
-1

Top
#178394 - 2007-07-25 12:43 PM Re: KiXgolf Freebie: Quicksum [Re: Witto]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
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.
_________________________
Every day is a school day

Top
#178395 - 2007-07-25 12:48 PM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
OK, I see
Top
#178404 - 2007-07-25 04:17 PM Re: KiXgolf Freebie: Quicksum [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wicked...
think the next golf round will be out of my reach.
at least it will be hard, if all of you guys participate.
_________________________
!

download KiXnet

Top
#178405 - 2007-07-25 04:27 PM Re: KiXgolf Freebie: Quicksum [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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
_________________________



Top
#178406 - 2007-07-25 04:55 PM Re: KiXgolf Freebie: Quicksum [Re: Jochen]
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
 Code:
* (trim($)=$)

nice test.
_________________________
Every day is a school day

Top
#178412 - 2007-07-25 05:36 PM Re: KiXgolf Freebie: Quicksum [Re: acmp]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 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

Top
#178419 - 2007-07-25 08:21 PM Re: KiXgolf Freebie: Quicksum [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
why trim()?
_________________________
!

download KiXnet

Top
#178420 - 2007-07-25 08:23 PM Re: KiXgolf Freebie: Quicksum [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
forget it, stupid q.

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

download KiXnet

Top
#178421 - 2007-07-25 08:28 PM Re: KiXgolf Freebie: Quicksum [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
and this would also yield 79:
 Code:
function a($)
    if $
        $a=right($,1)
        $a = a(left($,~)) + ($^) * (asc($a)-64) * ($a>!)
endfunction
_________________________
!

download KiXnet

Top
Page 8 of 9 « First<56789>


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.226 seconds in which 0.127 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