タオルの日を忘れた
$argv異なる結果を表示するための入力コメント/コメント解除の多いPHPスクリプト
ご存知かもしれませんが、5月25日はタオルの日としてよく知られています。これは、タオルの用途が多いためです。
本「ギャラクシーへのヒッチハイカーのガイド」の簡単な抜粋(個人的に私はこの本を「毎日のガイド」として取りました):
「タオルは、星間ヒッチハイカーが持つことができる最も有用なものに関するものです。部分的には、実用的な価値が非常に高いです。」
タオルに関する詳細情報が必要な場合は、このSE.scifiの回答を確認してください
チャレンジ
足の毛布として使用するタオルでこれを行うことを願っています。
2つの入力を受け取る有効なプログラミング言語で完全なプログラムまたは関数を記述します
size Integer : #The size
message string : #A sentence
これらの値でタオルを描く方法は?
最初の使用size:
入力したサイズに応じてタオルを描きます。タオルのascii-art
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
第二に、それを与える message
あなたはそれにメッセージを与える必要があります、黄金の糸で縫われた美しいメッセージのないタオルは何ですか?
例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
例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
"""""""""""""""""""""""" #
受け入れられた回答基準
- これはcodegolfなので、通常の規則が適用されます。
ルール
すべての入力文字列がサイズに適合することが保証されているため、などの入力はありません
size=1; message="This string is just tooooooooooooooooooooo long to fit the width and height of your towel"。たとえば、部分文字列を中央に配置する場合、文字列の形式はユーザー次第です。
単語の区切りは許可されていません。
編集
私が描いたansiiタオルがパラメーターと一致せず、予想される出力を確認するために両方の例にPHPスクリプトを追加したため、混乱について本当に申し訳ありません。
また、投票して私の最初の挑戦を検討したすべての人々に感謝します:D。
current line + next word私が投稿したPHPスクリプトが決定するように、タオルが@Jakobに許可されている制限を超える場合、改行を追加する必要があります。