← Back

You know ASCII art, right? For example, on a CLI where sentences are written using #’s. Like this:

# #  #  ### # #  #  ### ###  #  ###  
### # # # # # # # #  #   #  # # # #  
### ### # # ### ###  #   #  ### # #  
# # # # # # # # # #  #   #  # # # #  
# # # # # # # # # #  #   #  # # # # 

I encountered an algorithm problem that described how this worked! And it was interesting. If you want to display something on the terminal using # like that, how would you code?

The answer (or I guess most popular approach) is to pre-write all the characters and then kind of just “copy and paste” those pre-written characters. So for example first prepare something like this: abc

(excuse 1’s before ‘T’, just ignore them :P)

In this case, all letters are of the same width and height, so it’s easy to kind of programmatically copy and paste each character, given a sentence or a word you want to display. And the pre-written characters have no constraints in how they are designed. Look at this example: MHT

Furthermore, of course the characters don’t even have to be of the same dimensions, if the code can reflect the character design.

Pretty interesting, huh?