Movatterモバイル変換


[0]ホーム

URL:


Sorry, we no longer support your browser
Please upgrade toMicrosoft Edge,Google Chrome, orFirefox. Learn more about ourbrowser support.
Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities includingStack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Loading…
Code Golf

You are notlogged in. Your edit will be placed in a queue until it ispeer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Map inputted ASCII characters

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:

gif

After the user enters every ASCII character, the output should look like this:

table

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 ifend 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!

Answer*

More generally…

  • …Please make sure to answer the question and provide sufficient detail.

  • …Avoid asking for help, clarification or responding to other answers (use comments instead).

Draft saved
Draft discarded
Cancel
    Add a comment | 
    How to Edit
    • Correct minor typos or mistakes
    • Clarify meaning without changing it
    • Add related resources or links
    • Always respect the author’s intent
    • Don’t use edits to reply to the author
    How to Format
    • create code fences with backticks ` or tildes ~
      ```
      like so
      ```
    • add language identifier to highlight code
      ```python
      def function(foo):
          print(foo)
      ```
    • put returns between paragraphs
    • for linebreak add 2 spaces at end
    • _italic_ or**bold**
    • indent code by 4 spaces
    • backtick escapes`like _so_`
    • quote by placing > at start of line
    • to make links (use https whenever possible)
      <https://example.com>
      [example](https://example.com)
      <a href="https://example.com">example</a>
    • MathJax equations\$\sin^2 \theta\$

    MathJax help »

    How to Tag

    A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.

    • complete the sentence:my question is about...
    • use tags that describe things or concepts that areessential, not incidental to your question
    • favor usingexisting popular tags
    • read the descriptions that appear below the tag

    If your question is primarily about a topic for which you can't find a tag:

    popular tags »



    [8]ページ先頭

    ©2009-2025 Movatter.jp