Re: TI NSpire now supports user programs Message #4 Posted by Don Shepherd on 6 Oct 2007, 7:17 p.m., in response to message #3 by Bruce Bergman
It's a lot like BASIC, or TI-BASIC. Here is our HCC2007 programming contest (rearrange the digits of an input number into numerical order) done on the NSpire:
Define rev_digits(num)=Prgm
:Local i,a,n
:a:={}
:For i,0,iPart(log(num,10))
:a:=augment(a,{mod(intDiv(num,10^(i)),10)})
:EndFor
:SortA a
:n:=0
:For i,1,dim(a)
:n:=n+a[i]*10^(dim(a)-i)
:EndFor
:Disp n
:EndPrgm
I just get each digit of the input number and store it in a list, then sort the list, then convert the list items back into an integer number.
|