Page 1 of 4 1234>
Topic Options
#134092 - 2005-02-19 12:21 AM KiXgolf: Balanced Ternary Addition - Private Coding
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
=============
The Challenge
=============


Balanced ternary is a positional notation for expressing values in base-3, which uses the symbols -1, 0, and 1 as digits. To convert a balanced tertiary number to decimal, add together the position-dependent values of the digits. The value of the nth digit (counting from the right) is 3^(n-1). For example, the balanced tertiary number -110-1 has the decimal value 27*-1 + 9*1 + 3*0 + 1*-1 = -19.
Addition between two balanced ternary digits is defined by the following table:
Code:

+ | -1 0 1
-----------------
-1 | -11 -1 0
0 | -1 0 1
1 | 0 1 1-1



If the adding of two digits results in multiple digits, the results are carried over as in normal addition.
For example, adding together 1-1-1 (5) and 10-1 (8) results in 111 (13) as illustrated by the following diagram:
Code:

-1 -1
1 -1 -1
+ 1 0 -1
----------
1 1 1



Or, more detailed:
Code:

1 -1 -1
+ 1 0 -1
----------
-1 1
-1
1 -1
----------
1
-1 1
1 -1
----------
1
1
-1 1
1
----------
0 1 1 1




A download is available at http://people.bu.edu/jenmeyer/kixtart/kixgolf_bta.zip


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

Calculate the Balanced Ternary Addition based on two ternary inputs and output the result in ternary notation as well.


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


Inputs are two ternary notation numbers in the range of -255 and +255.
Output will be one ternary notation number.


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


All provided ternary number combinations must be correctly added to have a valid BTA 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, February 18, 2005 at 6:00pm EST
Private coding ends Tuesday, February 22, 2005 at 6:00pm EST
Public coding start Tuesday, February 22, 2005 at 6:00pm EST
Public coding ends Friday, February 25, 2005 at 6:00pm 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
================================================================


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 is syntactically correct with KiXtart.

4) The final solution MUST pass all test scripts that accompagny the KiXtart golf challenge.

5) The use of '$' as a variable is allowed.

6) In case of questions about a particular way to count the KiXtart Golf Challenge organizer has the last call.

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


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


1) Private coding phase: From date/time of posting the tournament challenge to Tuesday, February 22, 2005 at 6:00pm EST (BBS+6 time)

2) Public coding phase: From Tuesday, February 22, 2005 at 6:00pm EST (BBS+6 time) to Friday, February 25, 2005 at 6:00pm EST (BBS+6 time)

3) Final results: Friday, February 25, 2005 at 6:00pm EST (BBS+6 time)

You will need the complete package from http://people.bu.edu/jenmeyer/kixtart/kixgolf_bta.zip.
_________________________
There are two types of vessels, submarines and targets.

Top
#134093 - 2005-02-19 02:31 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah.
simple enough this time. should take no more than an hour.
your extra "explanations" got me actually more confused...
_________________________
!

download KiXnet

Top
#134094 - 2005-02-19 02:45 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Sealeopard Offline
KiX Master
*****

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

I've got my clock ticking...tick...tock...tick...
_________________________
There are two types of vessels, submarines and targets.

Top
#134095 - 2005-02-19 03:26 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
went to downstares and came back, read the task again and damn.
it wasn't as simple as I though
_________________________
!

download KiXnet

Top
#134096 - 2005-02-19 03:34 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
alrighty, I think I got the ternary to decimal part working.
the hard part that I missed on the first read, the encoding back... I still need to do that.
and fix the kixgolf.kix as it once again misses the wkix32 support.
and it trashes the output on 1 line.
missing "?" somewhere?
_________________________
!

download KiXnet

Top
#134097 - 2005-02-19 03:42 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
nah, my bad with the carbage
_________________________
!

download KiXnet

Top
#134098 - 2005-02-19 04:13 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
What do you want/need for the WKIX32 support?

A


? 'Press any key to continue...'
GET $sKey


sufficient?
_________________________
There are two types of vessels, submarines and targets.

Top
#134099 - 2005-02-19 04:21 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ja that would be sufficient in most cases.
_________________________
!

download KiXnet

Top
#134100 - 2005-02-19 04:24 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I got some problems with the encode decode stuff still but the results seem to be fine in decimal:
Quote:


KiXtart
KiXtart Version = 4.23
KiXGolf Script = kixgolf_bta.kix

Computer
OS = Windows XP Home Edition
CPU = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed = 2793 MHz
Memory = 512 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Balanced Terniary Addition
Processing Start = 2005/02/19 17:15:03.140
Processing End = 2005/02/19 17:15:03.406
Duration = 0000/00/00 00:00:00.266
# Tests Run = 106
# Tests Passed = 9
# Tests Failed = 97
Result = failed
KiXGolf Score = 193

Thank you for participating in KiXtart Golf!


_________________________
!

download KiXnet

Top
#134101 - 2005-02-20 02:10 AM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
347 ... and a headache ...
Top
#134102 - 2005-02-20 09:43 AM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think I figured it out when I couldn't sleep...
now need to test my theory...
_________________________
!

download KiXnet

Top
#134103 - 2005-02-20 10:14 AM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
alrighty... got it working. was worth the sleep
Quote:


KiXtart
KiXtart Version = 4.23
KiXGolf Script = kixgolf_bta.kix

Computer
OS = Windows XP Home Edition
CPU = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed = 2793 MHz
Memory = 512 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Balanced Terniary Addition
Processing Start = 2005/02/20 11:06:00.062
Processing End = 2005/02/20 11:06:00.187
Duration = 0000/00/00 00:00:00.125
# Tests Run = 106
# Tests Passed = 106
# Tests Failed = 0
Result = passed
KiXGolf Score = 335

Thank you for participating in KiXtart Golf!



_________________________
!

download KiXnet

Top
#134104 - 2005-02-20 11:47 AM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
should have read the mambo.
there is lot easier way to do this!
_________________________
!

download KiXnet

Top
#134105 - 2005-02-20 12:26 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ja, easier it is but somehow it still gets lot larger.
currently at:
KiXGolf Score = 430

think I abandon this one and go back to the shorter code...

[edit]
KiXGolf Score = 402

hmm... this is wicked way of coding... really wicked.


Edited by Jooel (2005-02-20 12:42 PM)
_________________________
!

download KiXnet

Top
#134106 - 2005-02-20 12:57 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
alrighty, back to the original code.
Quote:


KiXtart
KiXtart Version = 4.23
KiXGolf Script = kixgolf_bta.kix

Computer
OS = Windows XP Home Edition
CPU = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed = 2793 MHz
Memory = 512 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Balanced Terniary Addition
Processing Start = 2005/02/20 13:48:46.906
Processing End = 2005/02/20 13:48:47.031
Duration = 0000/00/00 00:00:00.125
# Tests Run = 106
# Tests Passed = 106
# Tests Failed = 0
Result = passed
KiXGolf Score = 327

Thank you for participating in KiXtart Golf!


_________________________
!

download KiXnet

Top
#134107 - 2005-02-20 01:15 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
323
322


Edited by Jooel (2005-02-20 01:27 PM)
_________________________
!

download KiXnet

Top
#134108 - 2005-02-20 01:57 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
295
284
276

Top
#134109 - 2005-02-20 02:59 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Ah, the battle is on
_________________________
There are two types of vessels, submarines and targets.

Top
#134110 - 2005-02-20 05:51 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no battle.
still at 318.

[edit]
297.


Edited by Jooel (2005-02-20 05:55 PM)
_________________________
!

download KiXnet

Top
#134111 - 2005-02-20 05:54 PM Re: KiXgolf: Balanced Ternary Addition - Private Coding
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
So, you're giving up?
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 4 1234>


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

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.075 seconds in which 0.024 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