View Full Version : Need Help With Some Basic Computer Science Knowledge
ppuchi
19-01-2004, 08:39 AM
"If the law is on your side pound on the law; if the facts are on your side pound on the facts; if neither is on your side pound on the table."
God, i need to compress this tongue twister by making up a dictionary: one "replacement phrase" per line; each line starts with a unique number followed by a decimal point; use an underscore to indicate a space. THen i need to type da encoded text!!:confused: da prof didnt say anything about dat...n i'm totally lost!!!
any one can help me out???
i'll appriciate it!
sorry, this is in the automotive forum because...?
Maestro
19-01-2004, 10:05 AM
Apart agreeing with Cray, this seems like a simple enough question. From your explanation, surely this is all you need:
Step one - lay out the problem:
1.If_the_law_is_on_your_side_pound_on_the_law;
2.if_the_facts_are_on_your_side_pound_on_the_facts ;
3.if_neither_is_on_your_side_pound_on_the_table
Step two - create code (define variables):
A=if
B=the
C=is
D=on
E=your
F=side
G=pound
H=law
I=facts
J=neither
K=table
L=are
Step three - substitution:
1.A_B_H_C_D_E_F_G_D_B_H;
2.A_B_I_L_D_E_F_G_D_B_I;
3.A_J_C_D_E_F_G_D_B_K
Please note that I did that manually so it's probably got errors, and I don't even know if it's what you're after. Plus I haven't done CS for about four years.
ppuchi
19-01-2004, 10:18 AM
sorry guys..i confess dat i messed it up:( partly because i dont really know how da forums work here~ n partly because i get pissed by da assignment~....i'm sorry..
but, thanx anyways~
btw..i did think of da way u did, but it seemed to be too simple to accept~~ i dont know..i'm just being weird..sorry guys
Maestro
19-01-2004, 10:24 AM
Why is it too simple? It compresses the phrase correctly... the only thing is that I may have misunderstood your initial post, so that instead of prefixing the parts of the phrase itself with numbers, the variables should be prefixed with numbers. So
1.A=if
2.B=the
etc etc
Something along those lines, anyway.
There is no more effective way to compress plain text than the way I gave you, unless you want to create a single mathematical equation to represent it (and I'm not about to try that). The way I gave you is 1 byte per word in ASCII (assuming that ASCII uses 8 bits per character, if I remember rightly), whereas the original is between 2 and 40 bytes per word.
You can makle a better dictionary. Such as the following
1._the
2.if
3._on_your_side_pound_on
4._is
5._law
6._facts
7._neither
8._table
9._are
2154315;2169316;274318
svvampy
19-01-2004, 10:36 AM
Jaz,
You can get rid of most of your underscores by setting the dictionary to include the underscores,
so 1 == if_ and so on.
heh. I realised that and was editing while you posted
svvampy
19-01-2004, 10:44 AM
Heh, still didn't fix makle.
ppuchi
19-01-2004, 11:44 AM
hmmm
how about dis?
1. if_
2. the_
3. law_
4. is_
5. on_your_side_pound_on_
6. facts_
ˇ°1234523;_126are_526;_1neither_452table.ˇ±
Tintin
19-01-2004, 12:25 PM
God is on my side and he will bring zgeek down.
P.S. This is a very interesting problem.
Originally posted by ppuchi
hmmm
how about dis?
1. if_
2. the_
3. law_
4. is_
5. on_your_side_pound_on_
6. facts_
1234523;_126are_526;_1neither_452table.
takes up less space, but thats if you are allowed to mix dictionary terms with uncompresses data.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.