仕事
小文字のASCII文字a
-の空でない文字列が与えられた場合、z
最初の文字を取り、そして:
- 2番目のキャラクターのコピーの正方形でそれを囲み、
- それを3番目のキャラクターのコピーのひし形で囲み、
- 4番目の文字のコピーの正方形でそれを囲みます…
…文字列の終わりまで正方形とダイヤモンドの境界を交互に切り替えます。ボーダー間の空のスペースは、ASCIIスペース()で表す必要があります。
正方形の境界線を追加するには、現在の「作業配列」全体を正確に囲むように正方形を描きます。
sssssssssss
t s t s
t t s t t s
t t s t t s
t aaa t s t aaa t s
t aca t => st aca ts
t aaa t s t aaa t s
t t s t t s
t t s t t s
t s t s
sssssssssss
ダイヤモンドの境界線を追加するには、最も外側の正方形に斜めに接触するが、直交しない中心に配置されたダイヤモンド形状を描画します。
s
s s
s s
s s
s s
s s
s s
wwwwwwwwwww s wwwwwwwwwww s
w o w s w o w s
w o o w s w o o w s
w o o w s w o o w s
w o eee o w s w o eee o w s
wo eme ow => s wo eme ow s
w o eee o w s w o eee o w s
w o o w s w o o w s
w o o w s w o o w s
w o w s w o w s
wwwwwwwwwww s wwwwwwwwwww s
s s
s s
s s
s s
s s
s s
s
プログラムは最終配列を出力する必要があります。
- 各行には、任意の量の末尾スペースを含めることができます。
- 行を表す文字列のリスト、またはオプションの末尾の改行で改行で区切られた単一の文字列を出力できます。
- 空白行の先頭/末尾は許可されません。
- スペースの先頭の列も許可されません。
これはcode-golfです。バイト単位の最短コードが優先されます。
テストケース
上記の例は、出力のために期待されているcat
、cats
、meow
、およびmeows
、順序を読んでいます。処理する価値のある他のケース:
入力
a
では、プログラムは次を出力する必要があります。a
入力
ab
では、プログラムは次を出力する必要があります。bbb bab bbb
入力
codegolf
では、プログラムは次を出力する必要があります。fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff f l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l ooooooooooooooooooooooooooo l f f l o g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g eeeeeeeeeee g o l f f l o g e d e g o l f f l o g e d d e g o l f f l o g e d d e g o l f f l o g e d ooo d e g o l f fl og ed oco de go lf f l o g e d ooo d e g o l f f l o g e d d e g o l f f l o g e d d e g o l f f l o g e d e g o l f f l o g eeeeeeeeeee g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g g o l f f l o g o l f f l ooooooooooooooooooooooooooo l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l l f f l f fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
リファレンス実装
プログラムの出力が(少なくとも視覚的に)一致するはずのジュリアコードをいくつか書きました。オンラインでお試しください!
\r\n
)ではなくそれぞれ2バイト()としてカウントしている可能性はあります\n
か?