TIB: letters
[Prev][Next][Index][Thread]
TIB: letters
>
> Okay, I read what u said, but I'm not sure what it is you are trying to do.
> I'll help if I can, please try to reexplain.
>
It appears as though I was perhaps not so clear. Here's a better
explaination. What I'm trying to do is re-create a bunch of
cryptography programs that I wrote a long time ago. Unfortunately, I
dropped my calc and the mem cleared before I could record them. :(
Anyway, as part of the program it was important to be able read an
input string, do something to it (the enciphering), and then to
display the new code. Well, like I said before, I'm using an 83, and
the only way I can think of to do this on my calc is to store each of
the letters as a number in a list. For example, the input might be my
name; JODY@SNIDER. The calc would read this one letter at a time, and
store it's corresponding letter into a list. Note the 'theta'. I don't
know about the TI-85, but the 83 won't recognize symbols, ie. + - _ (
).... Because of this, there is no way (that I know of) to have the
calc be able to read a _. To get around this, I just used the only
other easily accessible symbol on the keypad; the theta. Anyway,
JODY_SNIDER would end up looking like {10,15,4,25,27,19,14,9,4,5,18}
. Note that the theta is stored as 27. Well, that's whay I WANT to
happen, now the question is how to do it. The method that I used
before went something like this:
:1->A:2->B:3->C:4->D:5->E:6->F........25->Y:26->Z:27->@
:{0->L1:{0->L6
:Input Str1
:While L1(1)<length(Str1
:L1(1)+1->L1(1
:expr(sub(Str1,L1(1),1))->L6(L1(1)
:End
The reason for the list is simple; all of the 27 "easy" variable are
used up, and I find using lists is easier for me than using oddball
varibales like the statistic varibables.
You may have noticed how clumsy the 1->A:2->B:3->C... is. Just by
itself, it takes up 130 bytes, and it's a pain to type in. What I was
trying to do is come up with something smaller. Anyway, after about an
hour of experimenting after I made that posting, I was able to make
this work.
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ@->Str3
:Input Str1
:{0->L1
:For(K,1,lenth(Str1
:instring(Str3,sub(Str1,K,1->L1(dim(L1)+1
:End
This creates a list that looks like the above mentioned list, accept
the first element is a 0
The basic idea is real simple. If you look at Str3, each letter IS
already at the spot that corresponds to it number. ie, C is ALREADY at
the 3rd spot, T is ALREADY at the 20th spot, etc... The "instring"
command will do that, except that it need to look for another STRING
inside the big string. For instance, you can't just get
Instring(Str3,K because K is a number, not a string. However, if you
take a sub string in the Kth position that has a lenght of one, you'll
get a substring that is the letter that you want. Then take the
instring of that letter, and it will return the number of that
letter's position. The reason for the that extra 0 in the list is
because I was using the dimension of the list, instead of another
variable. It just stores the new number in the 'next' spot by taking
the dimension of the list now, and adding one to it, and storing it in
THAT spot.
The original idea uses 205 bytes, and the new version uses 87. Wow! A
savings of 118 bytes! Anybody out there have a better idea that's even
smaller?
Jody Snider
jody1@alaska.net