I forgot towel day
PHP script for both examples (error, formatting the string)
Corrected php script, the input is self explanatory
PHP script with more input comment/uncomment $argv
to see different results
As you may know, May 25 is well known as Towel Day, because of the many uses a towel can have.
A simple extract of the book "The Hitchhiker's Guide to the Galaxy" (personally I took this book as an "everyday guide") states:
"A towel is about the most massively useful thing an interstellar hitchhiker can have. Partly it has great practical value."
If you need more information about towels check this SE.scifi answer
The Challenge
Hopefully you will do this with a towel used as a blanket for your legs.
Write a full program or function in any valid programming language that takes two inputs
size Integer : #The size
message string : #A sentence
How to draw a towel with these values?
First using size
:
Draw a towel depending on the size input, ascii-art for our towel
width = 12*size
#the line that has the "bar" its always present with different sizes
Width is defined as:
from the first | to the second | has to be equal to size*12 including both ||
<- width->
[===| |====]
| 12 chars || 1 height starts here, just after the "bar"
| SIZE = 1 || 2
| || 3 height = 5*size
| || 4
| || 5 height ends here just before the first line |=======|
|==========|| # the lines with the #
|==========|| # are always fixed
""""""""""""| # it means, every towel
| | # always has this 5 rows
"""""""""""" # no matter the size
Second, give it the message
You have to give it a message, what is a towel without a beautiful message sewed in golden thread?
Example 1
input: size=1, message="a simple message can stay with size"
width = 12*size
#the line that has the "bar" it's always present with different sizes
#no words allowed at the bar level
[===| |====]
| a simple || 1 height starts here, just after the "bar"
| message || 2
| can stay || 3 height = 5*size
| with size|| 4
| || 5 height ends here just before the first line |=======|
|==========|| # the lines with the #
|==========|| # are always fixed
""""""""""""| # it means, every towel
| | # always has this 5 rows
"""""""""""" # no matter the size
Example 2
input size=2
message="Don't Panic and bring a towel to SE Programming Puzzles and CodeGolf"
The size is 2
That means 24 width and 10 heigth
<- 24 chars width ->
[===| |====]
| Don't Panic and bring|| 1
| a towel to SE || 2
| Programming Puzzles || 3
| and CodeGolf || 4
| || 5
| || 6
| || 7
| || 8
| || 9
| || 10
|======================|| # The lines with the "#"
|======================|| # always present and
""""""""""""""""""""""""| # adapted to
| | # the towel width
"""""""""""""""""""""""" #
Accepted answer criteria
- This is codegolf so normal rules apply.
Rules
You are guaranteed that all the input strings will fit the size, so no input like
size=1; message="This string is just tooooooooooooooooooooo long to fit the width and height of your towel"
.The string format is up to you, if you want to center the substrings for example.
Word-breaks are disallowed.
Edits
I am truly sorry about any confussion, because the ansii towels i draw did not matched the parameters, added a PHP script for both examples for you to check the expected outputs.
Also thank you to all the people who voted up and considered my first challenge :D.
current line + next word
will exceed the limit permited for your towel @Jakob as the php script i posted it decides. \$\endgroup\$