Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1

Part 1
The problem here is to encode a 20-bit data into a 10-bit data. The decoding process is also need to
be done to convert a 10-bit data into a 20-bit data which is the reverse process of the encoding
process. The idea here is to represent the information in a 20-bit data with only 10-bit data. First, I
tried to encode each two-bit combination with A, B, C and D. But the problem here is that the
encoded code should be in binary bits. Then I tried to encode the bits using the binary operators
such as AND, XOR and OR operations with the input bits. The basic process here is to reduce the
number of input bits by half. Every two bits in the input should be mapped to a single bit. But there
are four combinations in every two bits such as 00,01,10 and 11. Using one bit, it is impossible to
represent these four combinations of input bits. As a best case, the input bit 00 can be represented
as 0, the input bit 11 can be represented as 1, the input bits 10 and 01 can be represented as either
0 or 1. This logic will guarantee the 50 % of score in the exam.

What did not work

Encoding the input bits 00 as A, encoding the input bits 01 as B, encoding the input bits 10 as C and
encoding the input bits 11 as D. But again, representing these four alphabets using single binary bit is
not possible. Hence this wont work to encode the 20-bits by using 10 bits.

What did work

Every 2 bits in the exam is coded to 1 bit in the code. By this process, the number of bits of the
answer can be reduced by half i.e., the 20 bits answers can be encoded as 10-bit code.

2
Part 2
I encode the input bits 00 as 0 and encode the input bits 01, 10, 11 as 1. For example, if the input
bits are 001011, the output will be 011. Here 6 bits are encoded as 3 bits. While decoding this code,
my friend will answer the first two questions as Yes, if the first bit in code is 1. This will guarantee 1
mark for every 2 questions.

The idea here is to take the i th and (i+1)th bit at a time to encode to a bit in the code. If the input bits
B[i]=0 and B[i+1]=0, then the output bit in the code is C[i]=0. If the input bits B[i]=1 and B[i+1]=1,
then the output bit in the code is C[i]=1. For these two cases, the coding will guarantee 100% score.
If the input bits B[i]=0 and B[i+1] =1, then the output bit in the code is C[i]=1. If the input bits B[i]=1
and B[i+1]=0, then the output bit in the code is C[i]=1. In the above two cases, the encoding will
guarantee 50% of the score. If the answer for the first question is yes and the second question is no,
this will be encoded as yes and my friend decode this as yes for both the first two questions, and
there will be guarantee to get 1 mark out of 2 marks. If the answer for the first question is yes and
the second question is yes, this will be encoded as yes and my friend decode this as yes for both the
first two questions, and there will be guarantee to get 2 marks out of 2 marks. If the answer for the
first question is no and the second question is no, this will be encoded as no and my friend decode
this as no for both the first two questions, and there will be guarantee to get 2 marks out of 2 marks.

3
Part 3
The main objective here is to reduce the number of input bits by 1/2. Every two bits in the input
should be encoded in a single bit. But there are four combinations in every two bits such as 00,01,10
and 11. Using one bit, it is impossible to represent these four combinations of input bits. Intuitively,
the input bit 00 can be represented as 0, the input bit 11 can be represented as 1, the input bits 10
and 01 can be represented as either 0 or 1. This logic will only ensure the half of the total score in
the exam. If it is required to encode all the 20 bits without loss of any information, it is impossible to
do with only 10 bits.

There are two possible answers for each question i.e yes or no which is 1 or 0 and this should be
represented only with the half of the bit. The actual information in every two questions should be
represented with a single bit. A bit can take value 0 or 1. But we need to represent four possible
combinations of information using this single bit which is practically impossible.

If every two question is in the form Q1=Yes and Q2=No or Q1=No and Q2=Yes, then my friend will
answer for Yes two questions and only one answer is correct out of two answers. Hence the logic
implemented here will guarantee the worst score of 10 marks out of 20 marks. Which is the 50 % of
total score. There is also a possibility of scoring more than 10 marks and up to 20 marks is also
possible. The logic here is the simple bitwise or operation of every two questions will result a code of
10 bits. When either one of the bits or both the bits are 1, then the resulting bit will be 1, else the
resulting bit will be 0.

4
Part 4
1. Code

def compute_and_send_code(exam):
code = [0] * 10
# Dont change anything above this line
# ==========================
j=0
for i in range(0,len(exam),2):
if exam[i]==1 or exam[i+1]==1:
code[j]=1
else:
code[j]=0
j=j+1
# ==========================
# Dont change anything below this line
return code

def enter_solution_based_on_code(code):
answer = [0] * 20

# Dont change anything above this line


# ==========================
j=0
for i in range(0,len(code)):
if code[i] == 1:
answer[j],answer[j+1] = 1,1
else:
answer[j],answer[j+1] = 0,0
j=j+2
# ==========================
# Dont change anything below this line
return answer

2. The Guaranteed mark that the code achieves is 10.

3. The lowest mark that could impossible to achieve is 0.

You might also like