In this challenge, you must display ASCII art of a water balloon given the amount of water that the balloon is filled with:
| __||__ |
| / # #\ |
| |######| |
| |######| |
| |######| |
| |######| |
| |######| |
| \######/ |
| |
| |
+----------+
How to draw the balloon
To display a balloon of size n
, follow the following steps (note: whenever
the division symbol (/
) is used, it represents integer division, rounding
down):
Draw a container consisting of ten vertical bars (
|
) on the left and right, ten dashes (-
) on the bottom, and a plus sign (+
) in the bottom left and bottom right corner. This makes the whole thing 12x11, and the "inside" 10x10.| | | | | | | | | | | | | | | | | | | | +----------+
Draw two vertical bars (the opening of the balloon) centered in the middle of the top row, with
n/2
underscores (_
) on either side (for this example,n
will be 5):| __||__ | | | | | | | | | | | | | | | | | | | +----------+
Draw one slash (
/
) and one backslash (\
) surrounding this top row, one row below:| __||__ | | / \ | | | | | | | | | | | | | | | | | +----------+
Draw
n
rows of identically-spaced vertical bars, and then one row of a pair of (still identically-spaced) backslash and slash:| __||__ | | / \ | | | | | | | | | | | | | | | | | | | | | | \ / | | | | | +----------+
"Fill" the balloon with water, represented by a hash sign (
#
). Start at the lowest row, and work upwards. If a row is not entirely filled, you may place the hash marks wherever you want (in the below example, they are placed randomly, but you could put them, say, all on the left side if you want).| __||__ | | / # #\ | | |######| | | |######| | | |######| | | |######| | | |######| | | \######/ | | | | | +----------+
The maximum n
is 7, and the minimum is 0.
Input
The input will be an integer i
, which is the amount of hash marks (water)
that must be drawn.
It will never be less than 2, or greater than 100.
Output
The output should be a balloon of size n
containing i
hash marks (units of
water), where n
is the lowest possible size that can hold i
units of water.
Since i
will always be 2 or greater, n
will always be 0 or greater.
The maximum possible size a balloon can be drawn at is n
= 7. If a size 7
balloon cannot fit the amount of water specified, the balloon pops:
| |
| |
|## # ###|
|##########|
|##########|
|##########|
|##########|
|##########|
|##########|
|##########|
+----------+
(The above should be the output for input i
= 76. Just like the unpopped
balloon, the six extra units of water on the top row may be arranged however
you please.)
Test cases
Why have one test case, when you can have all of them?
Here's an animated GIF of all inputs i
from 2 to 100:
Scoring
This is code-golf, so the shortest code in bytes wins.