Question: Formalizing the Problem Formally, the ( correct ) exam answers consist of 2 0 true / false responses. We can represent these responses as a

Formalizing the Problem Formally, the (correct) exam answers consist of 20 true/false responses. We can represent these responses as a binary array B[0..20) where B[i]=1 if the (correct) answer to question i is true, and B[i]=0 if the (correct) answer to question i is false. Given the array B, your friend must determine a message M that she sends to you. We can similarly encode M = M[0..9) as a binary array containing only 10 values. Given the message M, you must determine your corresponding answers to the questions which we can represent as a binary array of length 20 A[0..19). The challenge is to determine an encoding scheme: An encoding function e : {0,1}20{0,1}10 from which your friend computes her message from the correct answers. That is, M = e(B).
A decoding function d : {0,1}10{0,1}20 from which you determine your exam answers from your friends message. That is, A = d(M). Given exam solutions B and your answers A, your score on the exam is score(B, A)=20 H(A,B), where H(A,B)=|{i | A[i]= B[i]}| is the Hamming distance between A and B. Your goal is to define encoding and decoding functions e and d that maximize your guaranteed score. That is, you wish to maximize the value G = min score(B,d(e(B)))B in {0,1}20. Note that this expression is the worst-case (i.e., lowest) score that your encoding scheme provides over all possible exam solutions.
implement an encoding scheme as described above in the Python programming language. To this end, you must complete the program exam_cheat_code.py by implementing two functions: encode(solutions: list[int])-> list[int] that takes as input a list of 20 binary (0-1) values representing the correct solutions to the exam (B), and returns a list of 10 binary values representing the message M to be relayed to you during the exam. decode(message: list[int])-> list[int] that takes as input a list of 10 binary values representing the message M you receive from your friend, and returns a list of 20 binary values representing the solutions A you submit for the exam. Your completed exam_cheat_code.py will be tested using the program exam_tester.py. This program iterates over all 220 possible exam solutions and finds the lowest score guaranteed by your implementation of the encoding and decoding functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!