Page 1 of 10 12345>Last »
Topic Options
#146548 - 2005-08-27 04:36 AM KiXgolf: Happy Numbers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
UPDATE
I was informed by one of the participants that the name of the function penalizes certain potential approaches. As it is not my intention, I will change the name of the function that is being called to a one-character name of A(). While technically this is not a rule-change, I do realize that it can potentially affect the outcome. I will therefore recognize two first-round winners, one for the tightest code before the function name change, and a second one, if necessary, for the tightest code after the function name change. I will also notify all participants via PM of this change.

The updated package is available at http://s91376351.onlinehome.us/kixtart/kixgolf_happy_numbers.zip


=============
The Challenge
=============


Let the sum of the square of the digits of a positive integer S0 be represented by S1. In a similar way, let the sum of the squares of the digits of S1 be represented by S2 and so on. If Si = 1 for some i >= 1, then the original integer S0 is said to be Happy number. A number which is not happy is called Unhappy number.

For example 7 is a Happy number since 7 -> 49 -> 97 -> 130 -> 10 -> 1 and 4 is an unhappy number since 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4.

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


=============
Specification
=============


Determine whether the numbers provided in the input is a happy or unhappy number.


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


Input : A single positive integer number
Output: 0 if input is an unhappy number and 1 if the number is a happy number


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


All provided integers must be correctly categorized in order to have a valid Happy Number UDF and to have the KiXgolf score count.


=============
General rules
=============


  • The UDF must be written as one or more lines.
  • The UDF is expected to finish in a reasonable time, e.g. if it gets started when the challenge opens, it's expected to be finished by the time the challenge closes even on a somewhat slow computer. The UDF has to be valid during the period that the challenge runs.
  • You can submit scores as often as you want until the deadline, there's no reason to wait until the last minute for a score submission. In fact, other people want to see the score to beat. So don't be a spoilsport by hoarding your score. Submit early and often.
  • The UDF may only use the KiXtart/KiXforms commands/functions/macros, no other code fragments are allowed. Calls to cOM components that are part part of a standard default Windows installation are allowed.
  • Calls to other executables, as long as they are part of a standard default Windows installation are allowed.
  • The use of the KiXforms DLL is also permitted as the KiXforms DLL can now be considered an integral part of KiXtart scripting.
  • 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.
  • You may assume ASCII as character set.
  • You are not allowed to use additional code that is external to the KiXgolf UDF Collection. All code must be contained within the KiXgolf UDF Collection.
  • You are allowed to only use publicly available versions of KiXtart and KiXforms, private builds or alpha builds are NOT allowed
  • Your submitted score must include the KiXart/KiXforms version used.

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.

========
Deadlines
========


Private coding starts Friday, August 26, 2005, 6pm EST
Private coding ends Wednesday, August 31, 2005, 6pm EST
Public coding start Wednesday, August 31, 2005, 6pm EST
Public coding ends Monday, September 5, 2005, 6pm EST


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


A test program is provided to help screen entries and to provide the Golf Score.
Any program that passes the test program can be submitted. If you are surprised that your solution passed the test program, 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[/CODE]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)[/CODE]for a score of 53.

Better approach: Code sample 1

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



  • The goal of KiXtart Golf is to score the lowest strokes.
  • 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.
  • Code can be constructed any way you like, as long as it is syntactically correct with KiXtart.
  • The final solution MUST pass all test scripts that accompagny the KiXtart golf challenge.
  • The use of '$' as a variable is allowed.
  • In case of questions about a particular way to count the KiXtart Golf Challenge organizer has the last call.
  • During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player.
  • During the public coding phase, code should be posted, reused, and borrowed from other players.
  • The test script contains the official KiXgolf scoring engine


Edited by sealeopard (2005-08-29 05:19 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#146549 - 2005-08-27 04:44 AM Re: KiXgolf: Happy Numbers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yehaa, finally.
so many hours wasted waiting.
just hope it was worth
_________________________
!

download KiXnet

Top
#146550 - 2005-08-27 04:46 AM Re: KiXgolf: Happy Numbers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
huh, happy happy or unhappy happy?
_________________________
!

download KiXnet

Top
#146551 - 2005-08-27 05:10 AM Re: KiXgolf: Happy Numbers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lets translate this to a formula please.
Quote:


Let the sum of the square of the digits of a positive integer S0 be represented by S1. In a similar way, let the sum of the squares of the digits of S1 be represented by S2 and so on. If Si = 1 for some i >= 1, then the original ...




what I read hear does not match your lines of results at all except that 7x7 is 49.
_________________________
!

download KiXnet

Top
#146552 - 2005-08-27 05:17 AM Re: KiXgolf: Happy Numbers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, I found an article that has some formula and explanation.
I shall read that one.
_________________________
!

download KiXnet

Top
#146553 - 2005-08-27 05:31 AM Re: KiXgolf: Happy Numbers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
7 -> (7x7)=49 -> (4x4+9x9)=97 -> (9x9+7x7)=130 -> (1x1+3x3+0x0)=10 -> 1
_________________________
There are two types of vessels, submarines and targets.

Top
#146554 - 2005-08-27 06:50 AM Re: KiXgolf: Happy Numbers
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
Okay... I must be dreaming or way over simplifying...

Here's my first attempt at playing KixGolf!

Quote:


KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = AMD Athlon(tm) 64 Processor 3200+
Speed = 2002 MHz
Memory = 510 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 00:27:00.015
Processing End = 2005/08/27 00:27:00.031
Duration = 0000/00/00 00:00:00.015
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 147





Now... can I make it any smaller?

Top
#146555 - 2005-08-27 06:50 AM Re: KiXgolf: Happy Numbers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I have a solution. I am happy.

Quote:



KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 01:04:36.750
Processing End = 2005/08/27 01:04:36.796
Duration = 0000/00/00 00:00:00.045
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 208

Thank you for participating in KiXtart Golf!




Sorry for the delay in posting the score. I had to download the scoring engine.

Since Allen and I had the same time on our solution do we tie for first on this round?


Edited by Chris S. (2005-08-27 07:26 AM)

Top
#146556 - 2005-08-27 07:08 AM Re: KiXgolf: Happy Numbers
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
Quote:


KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = AMD Athlon(tm) 64 Processor 3200+
Speed = 2002 MHz
Memory = 510 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 00:43:31.718
Processing End = 2005/08/27 00:43:31.734
Duration = 0000/00/00 00:00:00.016
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 146

Thank you for participating in KiXtart Golf!





-1 and I doubt I have anywhere else to go... Just betting my code to be 50 stokes higher than Lonks... I need a handicap to compete

Top
#146557 - 2005-08-27 07:54 AM Re: KiXgolf: Happy Numbers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I'm getting there...

Quote:



KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 01:34:14.812
Processing End = 2005/08/27 01:34:14.843
Duration = 0000/00/00 00:00:00.030
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 178

Thank you for participating in KiXtart Golf!




Top
#146558 - 2005-08-27 07:59 AM Re: KiXgolf: Happy Numbers
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
I didn't know it was a race to post working code... COOL! So what's the prize?
Top
#146559 - 2005-08-27 08:02 AM Re: KiXgolf: Happy Numbers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Quote:


KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 01:42:20.734
Processing End = 2005/08/27 01:42:20.765
Duration = 0000/00/00 00:00:00.030
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 165

Thank you for participating in KiXtart Golf!




Top
#146560 - 2005-08-27 08:43 AM Re: KiXgolf: Happy Numbers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Getting closer...

Quote:


KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 02:22:43.328
Processing End = 2005/08/27 02:22:43.359
Duration = 0000/00/00 00:00:00.031
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 152

Thank you for participating in KiXtart Golf!




Top
#146561 - 2005-08-27 08:58 AM Re: KiXgolf: Happy Numbers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Fah! I'm done for the night.


Quote:



KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 02:35:54.546
Processing End = 2005/08/27 02:35:54.578
Duration = 0000/00/00 00:00:00.031
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 151

Thank you for participating in KiXtart Golf!




Top
#146562 - 2005-08-27 09:45 AM Re: KiXgolf: Happy Numbers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Ok, I lied. I wasn't done.


Quote:



KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 03:25:29.593
Processing End = 2005/08/27 03:25:29.625
Duration = 0000/00/00 00:00:00.031
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 141

Thank you for participating in KiXtart Golf!




Top
#146563 - 2005-08-27 02:17 PM Re: KiXgolf: Happy Numbers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I think Jooel is still reading the rules
_________________________
There are two types of vessels, submarines and targets.

Top
#146564 - 2005-08-27 02:39 PM Re: KiXgolf: Happy Numbers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol, no.
I went to bed.
all the waiting for the start worn me down and I couldn't keep my eyes open anymore.
actually, I think I head back to bed now...
_________________________
!

download KiXnet

Top
#146565 - 2005-08-27 03:08 PM Re: KiXgolf: Happy Numbers
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Sleep away, Lonk. You snooze, you lose.


Quote:



KiXtart
KiXtart Version = 4.50
KiXGolf Script = kixgolf_happy_numbers.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Happy Numbers
Processing Start = 2005/08/27 08:48:16.687
Processing End = 2005/08/27 08:48:16.703
Duration = 0000/00/00 00:00:00.015
# Tests Run = 55
# Tests Passed = 55
# Tests Failed = 0
Result = passed
KiXGolf Score = 135

Thank you for participating in KiXtart Golf!




Top
#146566 - 2005-08-27 04:02 PM Re: KiXgolf: Happy Numbers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
if you really have working code this fast this small...
the challenge was too simple.
hmm...

I haven't had any time to think it over or start scripting as have some IRL stuff to intend.

what would you boys say if I was to skip this tournament?
seems like you had a fight on your hands without me
_________________________
!

download KiXnet

Top
#146567 - 2005-08-27 06:20 PM Re: KiXgolf: Happy Numbers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Jooel: So, you're willing to loose some points for the final year-end score and thus more or less forfeit a chance on first place?
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 10 12345>Last »


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

Who's Online
1 registered (Allen) and 286 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.082 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org