# Cheating a multiple choice test

### Introduction

While studying, I tried to come up with several ways to cheat a multiple choice test. It basically is a compressed version of the multiple choice answers. The method goes as following:

BCAABABA


These can be converted to 3 different arrays, which indicates true or false if the current letter is the answer:

    B  C  A  A  B  A  B  A
A: [0, 0, 1, 1, 0, 1, 0, 1]
B: [1, 0, 0, 0, 1, 0, 1, 0]
C: [0, 1, 0, 0, 0, 0, 0, 0]


Interpreting these numbers as binary would compress this a lot. But this can actually be compressed a bit more. If you know the positions of A and B, you don't need the positions for C. This can be done with a bitwise NOT operator:

A: [0, 0, 1, 1, 0, 1, 0, 1]
B: [1, 0, 0, 0, 1, 0, 1, 0]

A+B: [1, 0, 1, 1, 1, 1, 1, 1]
C:   [0, 1, 0, 0, 0, 0, 0, 0]


Converting the arrays A and B to binary numbers would result in:

A: 00110101
B: 10001010


That means that 8 multiple choice answers can be compressed to two bytes!

Given two numbers in binary, or two arrays consisting of only 0's and 1's with the same length, output the multiple choice answers

### Rules

• Input can be in the any form you like, like [1, 0, 0, 1] or 1001.
• You may provide a program or a function.
• You may assume that the input is always valid.
• You may also output as a list, separated with spaces, etc.
• The multiple choice answers only consist of A's, B's and C's. You may however use lower case instead.
• This is , so the submission with the least amount of bytes wins!

### Test cases

Input: [1, 0, 0, 1, 0, 0, 1] [0, 1, 0, 0, 1, 0, 0]
Output: ABCABCA

Input: [0, 0, 0, 0, 1, 0, 1, 1] [1, 0, 1, 0, 0, 0, 0, 0]
Output: BCBCACAA

Input: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Output: CCCCCCCCCC


var QUESTION_ID=69770,OVERRIDE_USER=34388;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important;font-family:Arial}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• Here is my solution. It is written in English (interpreter freely available wherever you are), and is Study.. Six bytes. Beat that. Commented Jan 20, 2016 at 19:01
• @CᴏɴᴏʀO'Bʀɪᴇɴ Sadly, English does not meet our standards of a programming language and is therefore not a valid submission :p Commented Jan 20, 2016 at 19:05
• You can actually compress eight multiple choice questions to 1.625 bytes (13 bits) by interpreting the answers as base 3, so technically this isn't the most efficient method. :P Commented Jan 20, 2016 at 23:29
• You could add another answer in the same space by using all four combinations of two bits, 00, 01, 10, 11 for answer a, b, c or d. You are not using 11. Commented Jan 21, 2016 at 9:23
• English satisfies all the criteria. The only problem is there isn't an interpreter available before this question is asked. Commented Jan 22, 2016 at 2:06

# PARI/GP, 45 bytes

This uses the multiif support from version 2.6.0.

f(u,v)=vector(#v,i,if(u[i],"A",v[i],"B","C"))


# C, 52 bytes

F(a,b,n){while(n--)putchar(a>>n&1?65:b>>n&1?66:67);}


The sequences of bits are interpreted as big-endian (MSB is the first answer), the third parameter n indicates the number of answers encoded.

Test main:

int main() {
F(73, 36, 7);
putchar('\n');
F(11, 160, 8);
putchar('\n');
F(0, 0, 10);
putchar('\n');
}


## Clojure, 41 bytes

(52 if a sequence of chars is not a permitted output format)

Finally a semi-cryptic Clojure answer :D Output as a sequence of characters:

#(map(fn[a b](or({1\A}a)({1\B}b)\C))% %2)


This version outputs a string:

#(apply str(map(fn[a b](or({1\A}a)({1\B}b)\C))% %2))


{1 \A} is a "dictionary" with key 1 and value character A. ({1 \A} a) returns \A if a is 1 and nil otherwise, same logic for b. or takes the first "truthy" value, which is \C if both a and b are zero.

# Vyxald, 10 bytes

~+†W∩vTkAİ


Try it Online!