TI-BASIC.
Integers.
Lists.
Matrices.
Do you know that they take up a bunch of memory in the RAM? One single TI-OS variable is 18 bytes, a list is 12+9*[dimension], and matrices 11+9*[width]*[height]. And often is that not necessary. Many people have booleans in their programs, like
not(A->A. You can store that in only 1 bit, instead of 18*8=144 bits....
And that is what this task is for. You need to compress data as much as possible, and then you're still not at the end. A very simple example of compressing, is storing booleans as bits, and not as 9-byte floating numbers, which saves much free space in RAM. Your task is to create a lossless compression algorithm (lossless = you can restore it to the original data).
Task #4:
Write an algorithm that compresses data without losing stuff. The input is a string in both Str1 and Ans, which contains a normal English text with these possible characters:
ABCDEFGHIJKLMNOPQRSTUVWXYZ_.,. Not more, not less (no lowercase letters!). The length is about 100 characters. Output is very simple: it can be anything, what you prefer, but remember what I said about integers, lists and matrices, which takes up much space. You may use ANY BASIC-command, because there is no compress-command
. You only need the compression algorithm for scoring, but
you should be able to decompress it as well! I say this, because otherwise people could say their algorithms are lossless, but in the meantime...
Extra: You can 10 points if can get the size < 5/10 of the original size
Anyway, to give you enough time, I decided to make #5 easy. In 2 weeks, this competition will be closed, so be sure to start today!
Score:
Not only speed and size is important, the compressed size too (without header!!!)
Ratio speed:compressed_size:size = 3:5:1
This would be an example as an input:
Code: "CHRISTOPHER LIVES IN NEW YORK CITY, ONE OF HIS SEVERAL LOVES ALONG WITH CALCULATORS, TECHNOLOGY, AND TRAINS."->Str1
prgmCOMPRESS
Good luck everyone, and have fun!