[Question]
  [
This is sequel to [this](https://codegolf.stackexchange.com/questions/69770/cheating-a-multiple-choice-test) challenge by [Adnan](https://codegolf.stackexchange.com/users/34388/adnan). If you like this challenge, chances are you'll like the other one too. Check it out!
---
A multiple choice test with 8 questions each with 4 choices might have the answers: `BCADBADA`. Converted to four different arrays, with true and false if the current letter is the answer, it will look like this
```
Q#: 1  2  3  4  5  6  7  8
    B  C  A  D  B  A  D  A
A: [0, 0, 1, 0, 0, 1, 0, 1]
B: [1, 0, 0, 0, 1, 0, 0, 0]
C: [0, 1, 0, 0, 0, 0, 0, 0]
D: [0, 0, 0, 1, 0, 0, 1, 0]
```
This can be compressed using a bit of logic. Each of the choices `A`, `B`, `C` and `D` can be represented
by two true/false values shown below:
```
A: 1 0
B: 0 1
C: 0 0
D: 1 1
```
Using this logic, we can compress the four vectors above to just two:
```
 1  2  3  4  5  6  7  8
 B  C  A  D  B  A  D  A
[0, 0, 1, 1, 0, 1, 1, 1]
[1, 0, 0, 1, 1, 0, 1, 0]
```
That is, the solution to your test is simply: `00110111`, `10011010`. By concatenating these, we get the binary number
`0011011110011010`, or `14234` in decimal. Use this decimal value to cheat on your test!
**Challenge**
Take a number `N` in the (inclusive) range `[0, 65535]`, and output a string with the answer to the multiple choice test.
**Test cases:**
```
14234
BCADBADA
38513
ABBDCAAB    
0
CCCCCCCC
120
CBBBBCCC
65535
DDDDDDDD
39253
ABCDABCD
```
The output may be in upper or lower case letters, but you can not use other symbols.
  
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), ~~19~~ ~~18~~ 16 bytes
### Code:
```
žH+b¦2äøC’c‰±’sè
```
Uses the **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=xb5IK2LCpjLDpMO4Q-KAmWPigLDCseKAmXPDqA&input=MTQyMzQ)
### Explanation:
First, we add `65536` to the number (`žH` is a constant defined to `65536`), which is also `10000000000000000` in binary. This is to pad the number with zeroes. Let's take the number `14234` as an example. `14234 + 65536` is equal to `79770`. Which in binary is:
```
10011011110011010
```
We remove the first character, resulting in:
```
0011011110011010
```
We split the string into two pieces using `2ä`:
```
00110111, 10011010
```
After that, we zip the array with `ø`:
```
01, 00, 10, 11, 01, 10, 11, 10
```
Converting them back into decimal (using `C`) results in:
```
1, 0, 2, 3, 1, 2, 3, 2
```
Now, we only need to index it with the string `cbad`. The compressed version for this string is `’c‰±’`, which can also be tested [here](http://05ab1e.tryitonline.net/#code=4oCZY-KAsMKx4oCZ&input=MTQyMzQ). Finally, we get the characters at the index of the above array. For the above example, this results in:
```
1, 0, 2, 3, 1, 2, 3, 2
b  c  a  d  b  a  d  a
```
[Answer]
## JavaScript (ES6), ~~55~~ 48 bytes
```
f=(n,i=8)=>i--?"CBAD"[n>>i&1|n>>i+7&2]+f(n,i):''
console.log(f(14234)); // BCADBADA
console.log(f(38513)); // ABBDCAAB
console.log(f(0));     // CCCCCCCC
console.log(f(120));   // CBBBBCCC
console.log(f(65535)); // DDDDDDDD
console.log(f(39253)); // ABCDABCD
```
### Non-recursive version (55 bytes)
Using a regular expression, we can do:
```
n=>"76543210".replace(/./g,i=>"CBAD"[n>>i&1|n>>+i+7&2])
```
[Answer]
# Python 2, 53 bytes
```
f=lambda n,k=8:k*'_'and f(n/2,k-1)+'CBAD'[n>>7&2|n&1]
```
Test it on [Ideone](http://ideone.com/ZcvrzF).
[Answer]
## [CP-1610](https://en.wikipedia.org/wiki/General_Instrument_CP1600) assembly, 24 DECLEs (30 bytes)
This code is intended to be run on an [Intellivision](https://en.wikipedia.org/wiki/Intellivision). (1)
A CP-1610 opcode is encoded with a 10-bit value, known as a 'DECLE'. The actual function is 24 DECLEs long, starting at `$4809` and ending at `$4820`.
The CPU registers are however 16-bit wide, so it will support any input value in `0x0000` .. `0xFFFF`.
```
                            ROMW  10            ; use 10-bit ROM
                            ORG   $4800         ; start program at address $4800
4800 0002                   EIS                 ; enable interrupts (to enable display)
                    ;; ---- usage example
4801 0001                   SDBD                ; load parameter in R0
4802 02B8 009A 0037         MVII  #14234, R0    ;
4805 0004 0148 0009         CALL  cheat         ; call function
4808 0017                   DECR  PC            ; infinite loop
                    ;; ---- 'Cheat Your Test' function
                    cheat   PROC  
4809 0082                   MOVR  R0,     R2    ; copy R0 to R2
480A 0040                   SWAP  R0            ; swap LSB/MSB in R0
480B 02BC 0214              MVII  #$214,  R4    ; R4 = pointer to 2nd row of screen memory
480D 01DB           @@loop  CLRR  R3            ; clear R3
480E 0052                   RLC   R2            ; extract highest bit of R2 to carry
480F 0053                   RLC   R3            ; inject carry into R3
4810 0050                   RLC   R0            ; extract highest bit of R0 to carry
4811 0053                   RLC   R3            ; inject carry into R3
4812 0001                   SDBD                ; add pointer to lookup table to R3
4813 02FB 001D 0048         ADDI  #@@tbl, R3    ;
4816 029B                   MVI@  R3,     R3    ; read character value
4817 0263                   MVO@  R3,     R4    ; write it to screen memory (also does R4++)
4818 037C 021C              CMPI  #$21C,  R4    ; 8 characters written? ...
481A 0225 000E              BLT   @@loop        ; ... if not, jump to @@loop
481C 00AF                   JR    R5            ; return
481D 011F 0117      @@tbl   DECLE $11F, $117    ; characters 'B', 'C', 'A' and 'D'
481F 010F 0127              DECLE $10F, $127    ; in white, using the built-in font
                            ENDP
```
### Output
[![screenshot](https://i.stack.imgur.com/YwEWM.gif)](https://i.stack.imgur.com/YwEWM.gif)
---
(1) Granted that at least [one compiler, several emulators](http://spatula-city.org/~im14u2c/intv/) and copyright-free [replacement ROM files](http://knox.ac.free.fr/files/intv-mini-roms.zip) are freely available, I think that it doesn't infringe any PPCG submission rule. But please let me know if I'm wrong.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
d⁹+⁹BZḄḊị“BADC
```
[Try it online!](http://jelly.tryitonline.net/#code=ZOKBuSvigblCWuG4hOG4iuG7i-KAnEJBREM&input=&args=MTQyMzQ) or [verify all test cases](http://jelly.tryitonline.net/#code=ZOKBuSvigblCWuG4hOG4iuG7i-KAnEJBREPigJ0KxbzDh-KCrFnigqxq4oCcwrbCtg&input=&args=MTQyMzQsIDM4NTEzLCAwLCAxMjAsIDY1NTM1LCAzOTI1Mw).
### How it works
```
d⁹+⁹BZḄḊị“BADC  Main link. Argument: n
d⁹              Divmod 256; yield [n : 256, n % 256].
  +⁹            Add 256; yield [n : 256 + 256, n % 256 + 256].
    B           Binary; convert both integers to base 2.
     Z          Zip; group the quotient bits with corresponding remainder bits.
      Ḅ         Unbinary; convert from base 2 to integer.
       Ḋ        Dequeue; discard the first integer, which corresponds to the
                dummy value introduced by adding 256 to quotient and remainder.
        ị“BADC  Index into that string, mapping [1, 2, 3, 0] to "BADC".
```
[Answer]
## [CJam](http://sourceforge.net/projects/cjam/), 22 bytes
```
ri2bG0e[8/:.{1$=)^'A+}
```
[Try it online!](http://cjam.tryitonline.net/#code=cmkyYkcwZVs4LzouezEkPSleJ0ErfQ&input=MTQyMzQ)
### Explanation
Powered by magic...
The mapping of bit pairs to letters in this challenge is a bit arbitrary. If we represent `ABCD` by `0, 1, 2, 3` (so we can just add them to the character `A`) then we want the following mapping:
```
i1   i2   o
0    0    2
0    1    1
1    0    0
1    1    3
```
This mapping can be computed with a magical little formula: `((i1 == i2) + 1) ^ i1`, where the equality check returns `0` or `1`. Check out the following table, where each column corresponds to one input, each row corresponds to one operation, and each cell will show the stack at that point:
```
[i1, i2]:  [0, 0]     [0, 1]     [1, 0]     [1, 1]
copy i1:   [0, 0, 0]  [0, 1, 0]  [1, 0, 1]  [1, 1, 1]
equals:    [0, 1]     [0, 0]     [1, 0]     [1, 1]
inc:       [0, 2]     [0, 1]     [1, 1]     [1, 2]
xor:       [2]        [1]        [0]        [3]
```
With that in mind here is the full breakdown of the source code:
```
ri     e# Read input, convert to integer.
2b     e# Get binary representation.
G0e[   e# Pad to 16 bits with zeros.
8/     e# Split into two halves of 8 bits each.
:.{    e# For each pair of bits, i1 and i2...
  1$   e#   Copy i1.
  =    e#   Check equality with i2.
  )    e#   Increment.
  ^    e#   Bitwise XOR.
  'A+  e#   Add to 'A'
}
```
An alternative solution with the same byte count which is decidedly less magical:
```
ri2bG0e[8/z2fb"CBAD"f=
```
And in case it's useful to anyone, if you turn the `i1` and `i2` bits back into a single number (i.e. when you want the mapping `0 -> 2, 1 -> 1, 2 -> 0, 3 -> 3`) this can be computed even more easily as `(~n - 1) & 3` or `(~n - 1) % 4` if your language gets modulo on negative values right. I think this can be written concisely as `3&~-~n` in many languages. In CJam this turns out to be a byte longer, because of the additional conversion back from base 2.
[Answer]
# PHP, 57 Bytes
```
for($i=8;$i--;)echo CBAD[($n=$argv[1])>>$i+7&2|$n>>$i&1];
```
Version without Bitwise operators 70 Bytes
```
for(;$i<8;)echo CABD[($s=sprintf("%016b",$argv[1]))[$i]+$s[8+$i++]*2];
```
[Answer]
# Mathematica, ~~75~~ ~~73~~ ~~68~~ 66 bytes
```
StringPart["CBAD",#+##+1]&@@IntegerDigits[#,2,16]~Partition~8<>""&
```
Thanks to @MartinEnder for saving 2 bytes.
[Answer]
# Perl, 42 bytes
Includes +1 for `-n`
Give input on STDIN:
```
perl -nE 'say+(A..D)[2-($`>>8-$_&257)%127]for/$/..8' <<< 39253
```
Just the code:
```
say+(A..D)[2-($`>>8-$_&257)%127]for/$/..8
```
[Answer]
# JavaScript, ~~113~~ ~~93~~ ~~90~~ 88 bytes
*A big thanks to @Neil for helping me save 20 bytes!  
-3 bytes thanks to @Cyoce*
```
n=>{r="";b=("0".repeat(15)+n.toString(2)).slice(-16);for(i=0;i<8;i++)r+="CBAD"[parseInt(b[i]+b[i+8],2)];return r}
```
```
n=>{r="";b=(65536+n).toString(2).slice(1);for(i=0;i<8;i++)r+="CBAD"[+b[i+8]+2*b[i]];return r}
```
```
n=>eval('r="";b=(65536+n).toString(2).slice(1);for(i=0;i<8;i++)r+="CBAD"[+b[i+8]+2*b[i]]')
```
```
n=>eval('r="";b=n.toString(2).padStart(16,0);for(i=0;i<8;i++)r+="CBAD"[+b[i+8]+2*b[i]]')
```
Sadly, JavaScript lacks functions like `decbin`, `bindec`, and `str_pad` that PHP has.
[Answer]
# MATL, 16 bytes
```
16&B8eXB'BADC'w)
```
[**Try it Online!**](http://matl.tryitonline.net/#code=MTYmQjhlWEInQkFEQyd3KQ&input=MTQyMzQ)
or [Verify all test cases](http://matl.tryitonline.net/#code=YAoxNiZCOGVYQidCQURDJ3cpCkRUXQ&input=MTQyMzQKMzg1MTMKMAoxMjAKNjU1MzUKMzkyNTM)
**Explanation**
```
        % Implicitly grab input
16&B    % Convert to binary string with at least 16 bits
8e      % Reshape the resulting string to have 8 rows and 2 columns
XB      % Convert each row from binary to decimal
'BADC'  % Push this string literal
w)      % Use the decimal numbers to index into this string (modular indexing)
        % Implicitly display the resulting string
```
[Answer]
# Julia, 73 Bytes
Gives a function f taking N as input and returning the answer as string.
```
f(N)=(b=bin(N,16);join(["CBAD"[parse("0b$(b[i])$(b[i+8])")+1]for i=1:8]))
```
[Try it](http://julia.tryitonline.net/#code=ZihOKT0oYj1iaW4oTiwxNik7am9pbihbIkNCQUQiW3BhcnNlKCIwYiQoYltpXSkkKGJbaSs4XSkiKSsxXWZvciBpPTE6OF0pKQpmb3IgTiA9IFsxNDIzNCwgMzg1MTMsIDAsIDEyMCwgNjU1MzUsIDM5MjUzXQogIHByaW50bG4oZihOKSkKZW5k&input=&args=)
Depending if a char array counts as string, one can omit the join (**67 Bytes**)
```
f(N)=(b=bin(N,16);["CBAD"[parse("0b$(b[i])$(b[i+8])")+1]for i=1:8])
```
[Try it](http://julia.tryitonline.net/#code=ZihOKT0oYj1iaW4oTiwxNik7WyJDQkFEIltwYXJzZSgiMGIkKGJbaV0pJChiW2krOF0pIikrMV1mb3IgaT0xOjhdKQpmb3IgTiA9IFsxNDIzNCwgMzg1MTMsIDAsIDEyMCwgNjU1MzUsIDM5MjUzXQogIHByaW50bG4oZihOKSkKZW5k&input=&args=)
[Answer]
## R, 110 bytes
Came up with a vectorized solution in R. This should probably by golfable by coming up with a smarter conversion int to binary conversion.
```
x=as.integer(intToBits(scan()));cat(LETTERS[1:4][match(paste0(x[16:9],x[8:1]),c("10","01","00","11"))],sep="")
```
]