Bob Ross' The Joy of ASCII Art
(Challenge added 558 days ago.)
Forget mountains, the future is ASCII Art.
The Problem
In this challenge, you will be given a set of instructions which, if followed correctly, will enable you to produce several images made up of ASCII characters.
More Information
- Your code will be given a number of lines on stdin. Each line is made up of three numbers separated by single spaces. Lines are separed by single newline characters.
The first and second number of each line represent the x- and y-coordinates on a grid where you should place the character represented by the third number. The third number is the ASCII value for the character you should place.
For example, the line :
3 5 65
instructs you to place the character 'A' (ASCII 65) at the co-ordinates (3,5) in the grid.- The grid's co-ordinate system is 0-indexed, so the top-left cell in the grid is referenced by the co-ordinates (0,0).
- Each x-coordinate will be in the range 0 to 79 inclusive, and the y-coordinates will be in the range 0 to 39 inclusive. Therefore the bottom-right of the grid is considered to be (79,39).
- The ASCII values you will be able to place in the grid will be in the range 32 to 126 inclusive. Empty cells in the grid are assumed to have the ASCII value 32 (' ', a space.)
- There is no limit to the number of lines you will be asked to process, and the order of the lines won't follow any particular pattern.
- Once you have processed each of the lines, the resultant grid should be printed to stdout. Each row in the grid which contains a non-empty cell should be output with any trailing spaces removed and a newline appended. Each cell in a row should be printed immedately adjacent to the previous cell. For example, an input of :
1 0 65 2 1 66 1 1 67 0 1 68
should produce the output :A DCB
(Note there is no space after the 'A' as trailing spaces should be removed, but there is one before it.) - Each submission will be run 8 times. It will need to pass all eight runs to be deemed successful.
Examples
You will receive the same input for each of the eight times your submission will be run. You can see the input and expected output for all eight runs below :
- Run 1 - YOU!
- Run 2 - Big Bunny.
- Run 3 - Small Bunny.
- Run 4 - Castle.
- Run 5 - Skull.
- Run 6 - Tux.
- Run 7 - Planet.
- Run 8 - Who you gonna call?
Thanks
Thanks to Ciaran for suggesting and submitting this challenge!
