TI-83+ BASIC Routines

Here are a few TI-83+ BASIC routines I came up with (note that some of the routines use Ans as an input, and sizes were calculated by typing in the code into the program editor, going to the memory menu, seeing how many bytes the program took up and then subtracting the length of the programs name from this amount):

Amount of digits in a real number (without converting to a string)

Ans->A
While fPart(Ans
10Ans
End
(Ans<0)+int(log(abs(Ans10^(2-not(fPart(A
...works with negative numbers and decimals too. (This is a smaller version of a routine I noticed here)

Detect Whether Ans is a String or a Number

30 bytes; works for any string and any number; puts 1 in Ans if Ans was initially a number and 0 in Ans if Ans was initially a string:
DelVar AFor(B,1,1
Ans->A
Ans->B
A=B
23 bytes; works for any string and any number except the empty string (the string that can be created by entering a quote on the home screen and pressing enter); puts 1 in Ans for a number and 0 in Ans for a string:
DelVar AAns->A
Ans=Ans+Ans or A
18 bytes; works for any string and any number except 0 and complex numbers; puts 0 in Ans for a number and 1 in Ans for a string:
DelVar AAns->A
not(A
The "not(A" line can be replaced with "not(real(A" in order to make it work for complex numbers too (I didn't know that not( didn't work with complex numbers at first, but Weregoose pointed this out).
See this thread for more information.

Encode string as a single positive integer (and decode)

Geometric Progression Test

not(variance(abs(ΔList(ln(Ansi
Given a list with at least three elements in Ans, returns 1 if the elements of the list follow a geometric progression and 0 otherwise. Note that the last character, i, is the result of pressing the 2ND key and then . (between the 0 and (-) keys).

(After browsing through a forum thread, I initially thought of:
ΔList(ln(Ans
not(variance(real(Ansconj(Ans 
I showed this to Weregoose as soon as I thought of it. He noticed a very nice optimization, and then DarkerLine followed with a tiny optimization after the routine had been posted, leading it to its current form)

Nth digit of a positive integer - 22 bytes

int(10fPart(A10^(B-2-int(log(A
This returns the Nth digit of a positive integer in A and a digit number, B, representing the Nth digit. The Nth digit is starting from the left-most digit - for example, in the number 264, 2 is the first digit.

Remove Duplicates in List - 42 bytes

The following routine only works with positive real numbers, meaning 0 also doesn't work
Here's a routine that makes it so that there is only one copy of element in the list in Ans (the resulting list is in Ans too) - 42 bytes:
Ans->A
{max(Ans
While min(Ans-min(LA
augment(Ans,{max((LA<min(Ans))LA
End

Smallest Quadratic Solver

Without having the user input something obscure like C/A, this is the smallest possible TI-83+ BASIC quadratic solver:
Prompt Y1,A,C
solve(Y1,X,5
{Ans,C/A/Ans
The input you would give when prompted would look something like this:
Y1=?"X^2+X-6"
A=?1
C=?-6
to solve the equation x^2+x-6=0, for example.

It's not very convenient to use, though - this, which was made by thornahawk, is a bit more convenient.


For more TI-83+ BASIC routines, visit Weregoose's pages here and here, the TI-BASIC Developer Wiki, the TI-BASIC board at UnitedTI and the TI-BASIC brain teasers subboard.

Back to Articles Archive
Hits: