Code:
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/23 13:08:30.437
Processing End = 2005/02/23 13:08:55.125
Duration = 0000/00/00 00:00:24.688
# Tests Run = 106
# Tests Passed = 106
# Tests Failed = 0
Result = passed
KiXGolf Score = 180
Thank you for participating in KiXtart Golf!


Code:

function bta($b, $c)
dim $,$x
if $c
for $=-729 to -$
$x=$x+$*($b=bta($,0))+$*($c=bta($,0))
next
$bta=bta($x,0)
else
do
$ = $b mod 3
if $/2 ; ternary 2 ?
$ = $/-2 ; change 2 to -1 and -2 to 1
$b = $b - $ ; carry forward
endif
$bta = "" + $ + $bta ; answer (coerce b to string with "")
$b = $b / 3 ; next base
until $b=0 ; done?
endif
endfunction

_________________________
!

download KiXnet