32
2
Be sure to see the other challenge, Reverse ASCII character map!
The ASCII charset (American Standard Code for Information Interchange) is the most widely-used character encoding standard. ASCII codes represent text in computers, telecommunications equipment, and other devices.
Challenge
Your challenge is to print a mapping of the ASCII character set as the user inputs them. GIF:
After the user enters every ASCII character, the output should look like this:
Mapping
Each character has an assigned position on a 16x6 logical grid, starting with the space character in the top left position, and wrapping such that the digit 0 appears below it.
When printable ASCII input is received, print that ASCII character at its assigned screen location without deleting any of the characters currently onscreen.
Rules
- Your program only needs to map out the printable ASCII characters,
0x20
to0x7E
. - Your program must not terminate and continue to map characters to the screen until all printable ASCII characters have been inputted. From here, your program can either terminate or run off into Neverland.
- Your program can map characters any way you like, e.g. to a spreadsheet, table, console window, or a graphical window.
- No matter how you display the mapping, it must be updated in realtime (as soon as it receives user input).
- If your program does not read input silently, it must put the cursor out of the way, so the text won't get in the way of the map.
Help
Here is the pseudocode algorithm I used to generate the GIF:
loop forever
c = input
y_coord = c / 16
x_coord = c - y * 16
if c is printable
print c at (x_coord * 2 + 1, y_coord + 1)
end if
end loop
There may be another way to achieve the required output. You can choose to use my algorithm or your own, but the output must be the same regardless.
Here's a useful ASCII table reference.
Scoring
The answer with the least bytes in each language wins. Have fun!
Do we need to have spaces between the characters? – musicman523 – 2017-06-03T00:28:17.253
@musicman523 Yep, those are necessary. The output must look exactly as shown in the screenshots. – MD XF – 2017-06-03T00:29:50.130
Are we allowed to assume the terminal's background color? – totallyhuman – 2017-06-03T00:38:21.470
Is clearing the terminal, then redrawing the updated table for each char acceptable? – Digital Trauma – 2017-06-03T00:40:14.920
@DigitalTrauma - Redrawing each time is acceptable - I asked in the Sandbox post – musicman523 – 2017-06-03T00:41:32.770
@totallyhuman yes, that's allowed. You don't have to do any sort of color changing. – MD XF – 2017-06-03T00:47:36.563
Can we assume that nothing but printable ASCII chars will be given as input? – ETHproductions – 2017-06-03T02:45:35.180
@ETHProductions yes, that's all right. – MD XF – 2017-06-03T03:54:46.257
Can there be a prepending space on each line? – dzaima – 2017-06-03T09:24:32.933
Can we substitute characters in languages that don't support all printable ASCII characters? – Scott Milner – 2017-06-03T21:35:21.073