It's my friend's birthday soon and since he is a programmer and ASCII art lover, I thought I'd make him some ASCII cake!
Sadly, I keep forgetting his current age, so I would like to have a program for my ASCII oven, that bakes a cake with a specified number of candles, so I don't have to do it myself again if I am wrong with his age.
ASCII ovens only have limited memory and storage capacity, so it should use the fewest bytes possible.
Write a program that outputs a birthday cake to the console, with as many candles as the input specifies.
Cake requirements are:
- It has to have a border, built up of horizontal
|lines, and vertices
- Atleast 5 characters wide (including cake border
- Atleast 5 characters high (including cake border
- There has to be a whitespace character
between the cake border and the first candle-base (not the flame), on each side, except if there is a flame in that space. A flame or candle-base should not be able to overlap the cake borders.
- The maximum width of the cake is 9 characters, so there is a maximum of 5 candles per row.
- Since we don't want our cake to be 2-dimensional, it has to be an extra 2 rows high, to give it some volume. Add another border at the bottom and connect the vertices with the ones above them, again using the ASCII characters from above (
Candle requirements are:
- Consists of the base
|and the flame
*, with the flame stacked on top of the base.
- Candles may not be directly adjacent to eachother, except diagonally.
- Candles are placed left-to-right, then top-to-bottom, with 5 in one line at maximum.
(Note: If there were 5 candles in the previous row, the next row can't possibly have 5 aswell, since then they would be adjacent.)
- The cake width depends on the number of candles in the first row, but it has to be a minimum of 5 characters and a maximum of 9 characters wide.
- The candles are filled starting in the top-most row, going left to right. Once one row if full the next one should start in the row below the first one.
You may accept a number in (reasonable) format you like.
For this challenge you may assume that the number is between 0 and 231 (not including 0), even though I don't acknowledge someone who is this old.
You can either return a string or directly write the resulting cake into the output console.
- Standard loopholes are forbidden.
- This is code-golf, so shortest code in bytes, in any language, wins.
+-----------+ | * * * * * | | |*|*|*| | | | | | | | | | +-----------+ | | +-----------+
+-----+ | * * | | | | | | | +-----+ | | +-----+
+-----------+ | * * * * * | | |*|*|*|*| | | *|*|*| | | | | | | | | | +-----------+ | | +-----------+