Introduction
Note: this is not some kind of method to encourage cheating. As Cᴏɴᴏʀ O'Bʀɪᴇɴ already said, studying is the best solution for passing a test :3.
Consider the following answers to the multiple choice test:
ABCBCAAB
Here is a table which indicates whether the answers match:
A B C B C A A B
A 1 0 0 0 0 1 1 0
B 0 1 0 1 0 0 0 1
C 0 0 1 0 1 0 0 0
This gives us the following numbers:
10000110, 01010001, 00101000
The challenge is to print these binary numbers. But it is important to see which letters are used in the multiple choice test. For example:
ABCDCDBCDABC
This highest letter is D
, which is the 4th letter in the alphabet. Therefore, we need to output 4 different binary numbers. Namely:
100000000100, 010000100010, 001010010001, 000101001000
Note that you have to look at the highest letter. Consider the following example:
AACCACAC
Although the B
is not used, we need to output the binary result for B
. That means, the answer would be:
11001010, 00000000, 00110101
Task
Given the answers to a multiple choice test, output the binary numbers. You may assume that the input will be non-empty and only containing the letters [A-Z]
. Instead of ones and zeroes, you may also use true and false.
Test cases:
Input: ABBBABABA
Output: 100010101, 011101010
Input: AAAAAAAAA
Output: 111111111
Input: AFGHEEHFD
Output: 100000000 000000000 000000000 000000001 000011000 010000010 001000000 000100100
Input: Z
Output: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
Input: ABCDCDBCDABC
Output: 100000000100, 010000100010, 001010010001, 000101001000
This is code-golf, so the submission with the least amount of bytes wins!
[a-z]
instead? \$\endgroup\$