Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Our groups weekly project is to make a program in Python that creates code and can decode messages based on the given code.
There would be three alternatives, X, Y and Z.
X is coded with binary string "0"
Y is coded with binary string "10"
Z is coded with binary string "11"

Our main issue is to get the program to analyze this code: "00101001100000" into the message it would give if the binary code got "translated" into the original message that would be presented in X, Y and Z. That would mean the message would show XXYYXZXXXXX. If anything I wrote is unclear please write back. I had to translate this from my mother tongue.
Posted

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

But this isn't complicated. Start by thinking how you would do it manually: you would look at a character from the input and decide if it's a zero or a one, then remove it from the list (hint: use an index, and all you have to do is increment it)
If it's a zero, you'd print an "X" and move on.
If it's a one, you do the same thing with the next character, and print a "Y" or a "Z" as necessary.
Continue until you run out of characters!
The only slight complication is making sure that if it ends with a one you don't fail - but that's pretty trivial when you think about it!

Try it! See what happens. You will learn a lot more by doing than by getting others to do it for you...
 
Share this answer
 
Oh ok, still thanks a lot, our deadline was midnight today, and as far as I can see most of our class had struggled way too much with this task. We are pretty new to python and programming in general. I totally get that you are not here to do my homework, so I'm sorry for asking too much. Still every clue helps a lot. I appreciate all help I can get. You see, we were forced to submit what we had done because of the deadline and I didn't want to move on while this task remains unsolved. So I'll use the hints you gave me and I'll try to solve it.

I'll also try to ask differently in the future and not ask for too much.
Again thanks a lot!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900