PDA

View Full Version : computer science homework



nathang1392
September 10th, 2009, 12:04 AM
im taking ap computer science at school over distance learning, i am usually pretty sure what to do, but this confuses me. i am given a code, of numbers, and i have to write an algorithm to decode these numbers: 220 241 255 245 052 313
311 052 312 303 052 312
252 245 052 205 241 251
253 243 052 203 253 302
251 244 303 301 053. the problem is that i cant figure out what the numbers decode to in the first place, anyone have any idea?

Bachstelze
September 10th, 2009, 12:06 AM
Maybe octal numbers that you need to convert to decimal? It's a bit weird that you're just given those numbers and "plz decode that kthx".

nathang1392
September 10th, 2009, 12:12 AM
its weird to me also. i dont necessarily have to decode it, but i have to write an algorithm. i also assumed they could translate into words somehow, but it doesnt make any sense.

#11u-max
September 10th, 2009, 12:56 AM
is it a hex code?

t0p
September 10th, 2009, 01:09 AM
If you don't understand your assignment, you should have a chat with your teachers. It's clear you have missed something somewhere along the line as the assignment doesn't make any sense the way you've presented it here. Decode numbers... into what? To decode something implies that there is a code. And a series of numbers is only a code if it is supposed to mean something.

Go talk to your teachers.

MaxIBoy
September 10th, 2009, 01:11 AM
I'm going to assume here that it's okay to give you suggestions on the code, since the real assignment is to "write an algorithm," but you're on shaky ground here, asking for homework help. Just putting that out there. I'm only helping because I find it to be an interesting problem myself.



If it was hex there would be As, Bs, Cs, Ds, Es, and Fs. In fact there doesn't seem to be anything over five.

I would say that each group of three digits is a byte but there are some which are more than 256.

Try treating each group of three as a three-digit octal number (9 bits.) Looking at these numbers, the most-significant bit is always zero. The highest number is 313 which from octal to binary is 11001011. This is only 8 bits. So try discarding the most-significant bit, then you have a round byte which could be ACII.

PurposeOfReason
September 10th, 2009, 01:14 AM
The instructor left something out, it is a CS class not a class to decode things. He should have said what they were coded with so that you could then decode it. That's like me giving you a slew of letters that were shift coded, not telling you, and letting you pick at it. It is a waste of time when the real goal is the algorithm.

MaxIBoy
September 10th, 2009, 01:37 AM
Maybe you're supposed to write a program to try different decoding methods, then automagically throw out any results which look like garbage?

PurposeOfReason
September 10th, 2009, 01:51 AM
I don't think so because that is assuming they know many different code methods and they don't assume things when you're a student. So unless you've been lectured on that, I don't think that's the goal.

OP, it would help to know how advanced this class is.

clonne4crw
September 10th, 2009, 02:02 AM
Maybe its Base64

lhowaf
September 10th, 2009, 02:26 AM
The only numbers present are 0 through 5. Therefor it is base 6.
Wouldn't that mean the first number (220) in base 10 would be (2 X 36) + (2 X 6) + (0 X 1)?

Hint: first word is "Take"

lhowaf
September 10th, 2009, 03:17 PM
You're welcome.

nathang1392
September 10th, 2009, 07:02 PM
just a question, once you convert the number to base 10, where are you getting the text from? how do you convert between decimal and text?

PurposeOfReason
September 10th, 2009, 07:19 PM
just a question, once you convert the number to base 10, where are you getting the text from? how do you convert between decimal and text?
Memorize this because if you plan to code a lot, you'll want to know all the letters:
http://www.asciitable.com/

LookTJ
September 10th, 2009, 07:26 PM
A little googling took me to a ascii table full of codes, however I will not link it. :) Base 10 to ascii

Nevermind, purposeofreason :)

lhowaf
September 10th, 2009, 08:17 PM
If you find an ASCII table in base 10 you can look up codes directly but most often they're in hex so you need to convert.
Look in your accessories for both a calculator and a character (ASCII) chart.

ve4cib
September 10th, 2009, 10:19 PM
Memorize this because if you plan to code a lot, you'll want to know all the letters:
http://www.asciitable.com/

There's also the ASCII man page:


$ man ascii