What are examples of great ASCII art
Frame this beautiful ASCII art
I think everyone agrees that beautiful pictures have to be nicely framed. But most of the challenges on this page about ASCII art just want the raw image and don't care about preserving it.
Wouldn't it be nice if we had a program that had some ASCII art in it and had a nice border around it?
Write a program that uses ASCII art as input and output, and is surrounded by a nice frame.
Example:***** *** * *** *****
becomes╔═══════╗ ║ ***** ║ ║ *** ║ ║ * ║ ║ *** ║ ║ ***** ║ ╚═══════╝
- You have to use exactly the same characters for the frame as in the example:
- The top and bottom of the frame are inserted before the first and after the last line of input.
- The left and right parts of the frame must be exactly one distance away from the widest line of the input.
- The output may not contain leading or trailing spaces. Only one final line is allowed.
- You can assume that the entry does not contain any unnecessary leading spaces.
- You can assume that the input does not contain trailing spaces on any line.
- You do not have to process empty inputs.
- The input contains only printable ASCII characters and line breaks.
- Function or full program allowed.
- Standard rules for input / output.
- Standard gaps apply.
- This is code golf, so the lowest number of bytes wins. Tiebreaker is an earlier template.
Have fun coding!
It is highly recommended that you use some great ASCII graphics created in every challenge on this website as it is highly recommended to type into your program and display it with a nice border!
CJam, 45 characters / 52 bytes
Trying to avoid those expensive 3-byte characters was ... interesting.
Try it out online
Haskell, 139 bytes
As an example I frame the snowman "12333321".
How it works:
This is 138 bytes in the IBM866 encoding, which is still supported in Firefox at the time of writing, but 152 bytes in UTF-8.
Example run from the script:
AWK, 159 bytes
Can apparently print unicode if you can figure out how to get it into the code.
(Score includes +5 for the interpreter flags)
First we find the longest line length by numerically sorting the lengths of all lines.
We set the header / footer as a repetition of the horizontal frame mark.
Then we print each line formatted to be left-justified in a field with a width between the border characters.
Pyth, 44 characters (58 bytes)
Check it out here.
This only works with the coding OEM 860. It is an extended ASCII superset used in Portuguese versions of DOS. Since I'm Portuguese (and loved making these "frames" in Pascal) and this is standard encoding, I did the following:
Here is the base64:
This answer was based on my answer at: https://codegolf.stackexchange.com/a/57883/14732 (the heavy lifting was all done there, just had to twitch a bit).
Looks less than 115 here, but the work file contains a 3-byte UTF-8 BOM signature that is incremented to 115 bytes. If you ran it in Python 3 you wouldn't need the parts list and it would come down to 112 bytes.
Golf function with dependencies; Takes entries as a zero-terminated character *
Somewhat ungolfed function in the full range
C Golf tips welcome!
- What's your ashes XI from 2019
- How many chins does Donald Trump have
- What happened to the white picket fence
- Why should you study in Germany?
- Why is Shiva represented as Aghori
- How are books rated according to age
- Why does Nigeria have corrupt leaders
- What does a bloody nightmare mean
- What does a district attorney do
- Capitalism takes advantage of Africa
- Powered subwoofers are good
- What is subcutaneous edema
- Why do scars itch when they heal
- Are car dashboard cameras legal in California
- Is it okay to ask personal questions
- How can I lose 5 kg easily
- What is rafting
- How do chemical and electrochemical corrosion differ?
- Are buffalo wings made from baby chicken
- How are the chess machines developed
- What is the best Mexican football team
- How do insurance companies detect a mistake
- What Causes Polycystic Ovarian Syndrome
- How do I bring discipline into life