18
3
Introduction
A code page maps integer values to a specific character. We can visualize a code page like this:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 0 | q | w | e | r | t | z | u | i | o | p | a | s | d | f | g | j | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 1 | k | l | y | x | c | v | b | n | m | Q | W | E | R | T | Z | U | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 2 | I | O | P | A | S | D | F | G | H | J | | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
The rows specify the first digit and the columns the second digit of the hex-number.
The Challenge
Given a string of 16-255 unique characters, output the corresponding code page using the zero-based index of each character in the string as it's value.
The input qwertzuiopasdfgjklyxcvbnmQWERTZUIOPASDFGHJ
for example would yield the table above.
- The output has to be in the exact same format as the table above. Only a trailing newline is optional.
- If the input length is not a multiple of 16, you need to start a new row for the remaining characters and leave the unused cells empty (=filled with 3 spaces).
- Each character is placed exactly in the middle of a cell, padded by one space to the left and right.
- The values in the first row and column are given by hex-numbers with the digits
0123456789ABCDEF
. Those are padded with one space to the left and right as well. You may choose to use lowercase hex-digits but you need to stick to one. - The only characters present in the output are hyphens
-
, pluses+
, pipes|
, spaces, the digits for hexadecimal numbers and the characters from the input.
- Any builtins that are related to ASCII-art tables or trivialize the problem in any way are forbidden.
- You may assume that the input consists only of characters of a specific encoding. Please specify if that is the case.
- If your language can only handle ASCII input, you may assume ASCII-only input and repeated characters.
Rules
- Function or full program allowed.
- Default rules for input/output.
- Standard loopholes apply.
- This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.
Happy Coding!
Can we use lowercase hex digits? – Doorknob – 2016-04-01T23:59:36.193
@Doorknob Yes, clarified it in the challenge. – Denker – 2016-04-02T00:00:57.337
1Can we assume the input is ASCII (with possibly repeated characters)? – Luis Mendo – 2016-04-02T00:05:35.090
@DenkerAffe That would conflict with the word "unique" or with "255" in Given a string of 16-255 unique characters, though... – Luis Mendo – 2016-04-02T00:07:36.610
@DenkerAffe It's a pity, because using non-ASCII will leave quite a few languages out. You could always allow sequences with repeated characters, and so allow ASCII-only languages too. The spirit of the challenge is not altered by that, and more languages can participate – Luis Mendo – 2016-04-02T00:12:07.080
1@LuisMendo Hmm yea, thats true. Gonna allow that for languages that can only handle ASCII. – Denker – 2016-04-02T00:14:53.067
@DenkerAffe Is it okay if the code page is not in exactly the same format as the one you show? – R. Kap – 2016-04-02T03:47:16.507
@R.Kap No, the output has to be exactly as specified. – Denker – 2016-04-02T12:35:19.777
@DenkerAffe I'm talking about the look of the page. For example,is it okay to print out the first row like
| 1 || 2 || 3 || 4 |...
instead of what you show in your example? – R. Kap – 2016-04-02T20:42:39.307@R.Kap That's not an example, thats the reference format. You have to use this and nothing else. Othwewise the answers wouldn't be compareable. – Denker – 2016-04-02T20:52:38.987
@DenkerAffe Ah, okay. I'll use that format then. – R. Kap – 2016-04-02T20:57:22.283
So you have a QWERTZ keyboard, right? – Erik the Outgolfer – 2016-09-04T20:14:55.560