[Math] How to create an array in TI-89 Titanium calculator

calculator

Has anyone experienced using TI-89 BASIC programming to solve math problems? I want to create an array using TI-89 but I don't know how?

Update
I tried both

{0, 0, 0, 0}->A

and

[0, 0, 0, 0]->A

Basically, I want to create a boolean array to check for duplicate digits of a number.

Update 1

dup(n)
Prgm
    {0,0,0,0,0,0,0,0,0,0}->a
    1->d // digit
    While n > 0
        mod(10,n)->d
        If a[d] = 0 Then 1->a[d]
        Else Return 1
        EndIf
        floor(n/10)->n
    EndWhile    
    Return 0
EndPrgm

Thanks,
Chan

Best Answer

I don't have an 89 at hand to check, but I suspect that you can use lists (contained in {}, comma-separated) in much the same way you'd use an array, including subscript-based accessing.


As it turns out, I do have a TI Voyage 200, which is functionally identical to a TI-89 Titanium (runs the same OS, but more memory, better screen, QWERTY keyboard). I am able to store a list into a variable:

{2,4,6,8}->a (where -> is the "sto>" key)

and access items in that list:

a[3] is reformatted as $a_3$ and returns 6.

In what way was {0, 0, 0, 0}->A not working for you?


Okay, here are some relatively messy thoughts, but hopefully some of it will be helpful. You can create a list of the digits in a number n with

seq(mod(floor(n/10^k),10),k,0,floor(log(n)))->digitList

(the ones digit will be the first item in the list, ...)

Now, having a list of the digits, you can sort the list using

SortA digitList

Construct a list of the differences between successive terms of digitList (where there will be 0s for duplicated digits):

∆List(digitList)->deltaList

Now, you can do something like looping over deltaList and whenever you find a zero, check the corresponding location in digitList to see which digit is repeated.

Alternately, you could step through the sorted digitList, tracking the previous entry, and find duplicates that way.

Related Question