Well, here's a difficult problem that I haven't the creativity to find the solution to...yet. Say for example that "ABCD" is in Str1 and there is a prgm as follows:


Code:
:"ABCD->Str1
:Prompt Z,N
:sub(Str1,N,1
:Some algorithm to store the value of Z into the Nth variable in Str1


For example, if 666 is the value inputed for Z and 3 for N, then 666 will be stored to C (third letter in Str1).
I'm looking for a space optimization here. I know you can just do:


Code:
:If N=1
:Then:Z->A
:Else:If N=2
:Then:Z->B
:Else:If N=3
:Then:Z->C
:Else:Z->D
:End
:End
:End


But all that is just for being able to select A through D; if I wanted to go up to Z, think of the amount of lines I'd have to add.

I've encountered this problem a couple times before and just encountered it again when making a Hess' Law (enthalpy changes) program. I think such a tool would be useful in the programmers bag of tricks. Oh yeah, and no assembly allowed. Kudos to anyone who can solve this possibly impossible problem.

I tried an approach like:

Code:
:sub(Str1,N,1
:expr("solve(Z-"+Ans+","+Ans+",0"


Unfortunately unlike doing a manual solve, the variable isn't updated to the solved value and all that happens is Z is stored to Ans. Sigh.

Btw, for the recent contest I didn't get around to fixing up my prgm to a state where I thought it would be exceptional. It involved the Riemann Zeta function but I'll leave it at that. Post-contest a RAM clear got rid of it, but it's okay, it isn't too difficult to remake. Whenever a math prgming contest comes around...
The best I would be able to come up with would be something like


Code:
Z:If N=1:Ans->A
If N=2:Ans->B
If N=3:Ans->C
If N=4:Ans->D
...ad infinitum...


Anyone else have some ideas? I always wanted to implement this kind of thing for storing to lists with arbitrary names, but I never got around to it. Smile

Edit: I need to start thinking when I type. What I was actually trying to say was that I never *succeeded with it.
Unfortunately, it seems you can't do this without something like the indirection command on the TI-89. Sad
You could use Celtic to create a program that simply does "Ans-->Variable"... it would be a bit slow though, and would probably take more space due to Celtic's size.... but it would be a far simpler approach than "manually" storing each value.

Personally, I would just use a list, but if you really need to use variables such as A-Z, then there isn't much I know that can help....
Yeah, I'd agree that a 26-element (or however many) list would be the best solution here. Smile
Yeah, a list would almost always be preferable. The only thing is that individual values in a list cannot be Solve()'d which was the dilemma I was running into when making that Hess Law program. Anyways that program isn't very useful anymore anyways since the homework and test that required that program are in the past. Guess I'll save it until the IB exam comes 'round.

Even though I'm totally enamored by all the things the calculator can do I always find limitations or inconveniences. If only matrices could have complex values and sum(seq()) could be used inside seq() instead of getting an "ERR: ILLEGAL NEST" and having to use For().

Sher kant wate to get me to sum colij an' get mehself ejewcated in sumuh dat kumpooter prograhmin' mumbo jumbo. After such education I am quite sure that I would be relinquished from such creative confinement.
It's sounds to me like you'd greatly benefit from learning how to do some Matlab programming, which can easily do this kind of thing. :) Granted, you still can't do indirection perfectly, but you can solve for an equation involving vector elements.

Edit: oops, I'm Kerm, posted under the wrong account by accident.
monstachyld wrote:
It's sounds to me like you'd greatly benefit from learning how to do some Matlab programming, which can easily do this kind of thing. Smile Granted, you still can't do indirection perfectly, but you can solve for an equation involving vector elements.


seconded.... but you can't exactly bring a laptop to a test =D What you could do is associate matrix elements with a list... but again, thats painfully slow and eliminates most functionality....
Yes, I definitely can't wait for college. I've been accepted to only one so far and will be doing computer science if I go there, so I'm sure I'll be introduced to Matlab eventually.

rthprog wrote:
seconded.... but you can't exactly bring a laptop to a test =D What you could do is associate matrix elements with a list... but again, thats painfully slow and eliminates most functionality....


Well, I only really needed to do 6 or 7 variables anyways, so I wouldn't have to go all the way up to Z. Anyways, I just thought it would have been cool if someone had thought of a way to do this. Similar to the nice trick of storing a value to a string by using the calculator's linear regression.

The different type of thought process introduced to me through TI-BASIC is what made me want to get into computers more. I considered electrical engineering but thought computer science would fit me better; that and I'm not too good at physics.
computer science is a great field to get into. Very few people are trained for problem solving anymore, and its a great skill to have in your toolkit. If you're interested in learning some programming on the computer, you should check out Python.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement