Does anyone have a way to encode/decode a string as a number?

I need this for sending/storing names as part of a list.

There is the String to List routine:

```
:DelVar L₁
:For(A,1,length(Str1
:inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",sub(Str1,A,1→L₁(A
:End
```

And with compression, you can simplify that list down to a number. With a base compression on base 26, you can store a string of up to 9 characters in a number (because int(ln(10^14)/ln(26))=9).

Something like this:

```
:0
:For(A,1,dim(L₁
:26Ans+L₁(A
:End
:Ans→A
```

And the number will be in variable A. Hope that helps!

Wow, didn't know that was possible

The man shuddered as the shadow drew a glistening sword from his back. Creeping closer and closer with his pale eyes burning into the man, the shadow slowly raised his blade and before he could thrust it down, the man heard the shadow hiss something.

"The Shadow Clan's presence must be like a whisper. Always felt, but never seen…"

Even better, use seq( and save yourself some time:

`seq(inString("ABCDEFGHIJKLMNOPQRTSUVWXYZθ.?!",sub(Str0,A,1)),A,1,length(Str0`

You could then use a variant of your second code to convert the outputted list into a single number. As noted, you're limited to 9 chars in a number, but you can't do anything about that, that's about as compressed as you're going to get.

How do I convert a math problem string (say, 2+2) into a variable? If I could do this, I could make a program to increment X by a small decimal number to solve algebra problems…

Coffee + Radiohead = ^^

You can just use a different reference string than "ABCDEFGHIJKLMNOPQRSTUVWXYZ" and use a string like "0123456789+-*/" and whatever other math symbols you want. And then use the same methods as above with that variant. As long as you use the same reference string to convert back, it should work.

Would this work?

```
:DelVar L₁
:ClrHome
:Input "----PROBLEM:----",Str1
:Disp "Loading...
:For(X,-1000,1000,.001
:For(A,1,length(Str1
:inString("0123456789./+*X-=<>^()!",sub(Str1,A,1→L₁(A
:End
:0
:For(A,1,dim(L₁
:26Ans+L₁(A
:End
:Ans→A
:If A=1
:Pause X
:End
```

If so, it would solve any algebra problem with X and an answer that is >-1001, <1001, and has equal to or less than three decimal places…

Coffee + Radiohead = ^^

It could work, maybe, but if it did, it would take you a very, very long time. Have you considered maybe using expr(?

Eeerm… For what you're doing… I think I misunderstood you when I answered. Instead of my code, you should just use expr on your string.

Better, you should just use the solve( function…

My idea is to Input an expression (i.e., 4=2x^{2}-5), then to increment X by something small and auto solve it to the variable A as 1 or 0. However, I need a way to store the problem in something manageable to convert to a yet keep it intact for every increment.

Coffee + Radiohead = ^^

I made a way using sub(, InString(, and For(, to store the contents to a list (number of _, what slot they are in, ect.) However, it is pretty inefficient and uses a lot of memory and time. If there was a *conversion routine*…

Coffee + Radiohead = ^^

Yup: Just keep it in a string or an equation variable or a sequence variable.

This would work:

```
:Input "----PROBLEM:----",Str1
:For(X,-1000,1000,.001)
:If expr(Str1
:Pause X
:End
```

Now, if you wanted to try to solve it in a NON brute force/montecalro method, that would be hard…

You would have to add in a form of PEMDAS for algebra.

Coffee + Radiohead = ^^

Doesn't the TIOS automatically do PEMDAS?

Well, you would have to modify it (subtract 5, multiply both sides by three, ect.).

Coffee + Radiohead = ^^

No.

Say, for example:

15x-9=4x+5

We know with Algebra that 11x-9=5; and then 11x=14; so x=14/11.

But when the For() loop reached 1.27272727272727, it it would process 10.0909090909=10.09090909; it would be true. You would of course have to change the increment to 10^-14, as that is the calculator's precision. And it would take quite a while at such a small increment. And it would only find real numbers. Yes, if you processed it all with your own CAS, it would be much more efficient. But this way's easier.