• Welcome to Valhalla Legends Archive.
 

TI83+

Started by mynameistmp, November 16, 2003, 02:32 PM

Previous topic - Next topic

mynameistmp

i'm programming a project in BASIC. it prompts for a UPC ID, the program spits out the typical length of the given product. there is a fairly lengthy list of products. does anybody know of an efficient method to do this ? (or, in any case, the _most_ efficient method). any input is greatly appreciated
"This idea is so odd, it is hard to know where to begin in challenging it." - Martin Barker, British scholar

dxoigmn

Quote from: mynameistmp on November 16, 2003, 02:32 PM
i'm programming a project in BASIC. it prompts for a UPC ID, the program spits out the typical length of the given product. there is a fairly lengthy list of products. does anybody know of an efficient method to do this ? (or, in any case, the _most_ efficient method). any input is greatly appreciated

Hash table?  This solves the time problem, but is a bitch with space.  If you're programming for a TI-83+, that could be a potential problem.

mynameistmp

well something along the lines of a hash table was what i had in mind, i'm just not sure how to go about doing that. any suggestions ?
"This idea is so odd, it is hard to know where to begin in challenging it." - Martin Barker, British scholar

iago

In BASIC, I'm not too sure.  Can you convert a string to a uniquish number, and store the string in an array at that number?

If so, you need an array of strings that's a prime numbered size, to insert hash it and try to insert; if something that's not the string is there, increment by some value (mod tablesize) and try again, till either you find it's already there or you find an empty spot.

It's not the best way to do it, of course, but it's easy to insert stuff.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Skywing

Quote from: iago on November 18, 2003, 05:18 PM
In BASIC, I'm not too sure.  Can you convert a string to a uniquish number, and store the string in an array at that number?

If so, you need an array of strings that's a prime numbered size, to insert hash it and try to insert; if something that's not the string is there, increment by some value (mod tablesize) and try again, till either you find it's already there or you find an empty spot.

It's not the best way to do it, of course, but it's easy to insert stuff.
I think that you would turn a string to a hash value the same way you would in any other language, e.g. writing a hash function that accesses all the elements and combines them in some manner, such as xoring (at the most basic)?

iago

Quote from: Skywing on November 19, 2003, 07:04 AM
Quote from: iago on November 18, 2003, 05:18 PM
In BASIC, I'm not too sure.  Can you convert a string to a uniquish number, and store the string in an array at that number?

If so, you need an array of strings that's a prime numbered size, to insert hash it and try to insert; if something that's not the string is there, increment by some value (mod tablesize) and try again, till either you find it's already there or you find an empty spot.

It's not the best way to do it, of course, but it's easy to insert stuff.
I think that you would turn a string to a hash value the same way you would in any other language, e.g. writing a hash function that accesses all the elements and combines them in some manner, such as xoring (at the most basic)?

You can add them for all I care :)

It's the array of strings that I'd be more worried about not being able to do.  I don't know how TI-83's basic works.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


CupHead

First of all, the TI-83 has 10 strings.  I don't know about the 83+s.  The string handling functions it has are limited, but you could probably make do with them.