前書き:
私たちがレディバグについて考えるとき、私たちは通常、黒い斑点が付いた赤か暗いオレンジのバグを考える。これは必須ではありませんが、黒色の赤かオレンジ色の斑点が付いた、または斑点のない虫歯、これは主に以下のような何かかの写真を描いています。Asian
Ladybug:
注目すべきもう一つのことは、アザミウマの斑点はほぼ常に対称的であるということです。それがこの挑戦の舞台です。
チャレンジ:
Given an integer n
(>= 0
), output
the following ASCII-art ladybug one or multiple times, with
symmetric spots evenly divided between the two sides, as well as
the two or more ladybugs.
以下はデフォルトのひな鳥レイアウトです:
_V_
/(@[email protected])
/ |
| | |
| /
''-!-''
n = 0
の場合、上記のようにひな祭虫を出力します。
n
が0より大きい場合、ASCIIアートのバグのスペースを小文字の o
で埋めるか、 |
をセンターは大文字の O
です。目指すのは、(空腹虫あたり)対称的な出力を生成しながら、できるだけ少数のミツバチを出力しながら、空のミツバチに
n
変更を加えることです。
したがって、 n = 1
の有効な出力は次のとおりです。
_V_
/(@[email protected])
/ O
| | |
| /
''-!-''
_V_
/(@[email protected])
/ |
| O |
| /
''-!-''
_V_
/(@[email protected])
/ |
| | |
O /
''-!-''
しかしこれは無効です:
_V_
/(@[email protected])
/ |
| o | |
| /
''-!-''
n = 2
の有効な出力は次のとおりです。
_V_
/(@[email protected])
/ O
| O |
| /
''-!-''
_V_
/(@[email protected])
/ O
| | |
O /
''-!-''
_V_
/(@[email protected])
/ o|o
| | |
| /
''-!-''
_V_
/(@[email protected])
/ |
| o | o |
| /
''-!-''
etc. There are a lot of possible outputs.
もう1つのladybugに収まりきらない最初の n
は n = 24
です。その場合は、できるだけ均等に2つのミツバチに分けなければなりません(お互いに隣り合うか、お互いの下に出すかを選択できます –
オプションで1つの空白または1つの改行を必要に応じて選択できます)。例えば:
_V_ _V_
/(@[email protected]) /(@[email protected])
/o o|o o /o o|o o
|o o | o o||o o | o o|
o o|o o/ o o|o o/
''-!-'' ''-!-''
OR:
_V_
/(@[email protected])
/ooo|ooo
| | |
ooo|ooo/
''-!-''
_V_
/(@[email protected])
/ooo|ooo
| | |
ooo|ooo/
''-!-''
挑戦のルール:
-
n
will be in the range of
0-1000
. - You can choose to output to STDOUT, return as String or 2D-char
array/list, etc. Your call. - Leading new-lines or unnecessary whitespaces aren’t allowed.
Trailing white-spaces and a single trailing new-line are
allowed. - As mentioned above, when two or more ladybugs are necessary,
you can choose whether to output them next to each other or below
each other (or a mix of both..) - When two or more ladybugs are printed next to each other, a
single optional space in between is allowed. When two or more
ladybugs are printed down one another, a single optional new-line
in between is allowed. - You can choose the layout of the ladybugs at any step during
the sequence, as long as they are symmetric and equal to input
n
. - Since the goal is to have
n
changes AND as few
ladybugs as possible, you will start using more than one ladybug
when aboven=23
. The layout of these ladybugs doesn’t
necessary have to be the same. In fact, this isn’t even possible
for some inputs, liken=25
orn=50
to
name two. - In addition, sometimes it isn’t possible to evenly split the
dots among two or more ladybugs. In that case you’ll have to split
them as evenly as possible, with at most a difference of 1 between
them.
したがって、最後の2つのルールを念頭に置いて n = 50
の場合、これは有効な出力です(最初のバグは16個、残りの2個は17個です)。
_V_ _V_ _V_
/(@[email protected]) /(@[email protected]) /(@[email protected])
/oooOooo / O /o oOo o
|ooooOoooo||ooooOoooo||o ooOoo o|
| / oooOooo/ o oOo o/
''-!-'' ''-!-'' ''-!-''
一般的なルール:
- This is code-golf,
so shortest answer in bytes wins.
Don’t let code-golf languages discourage you from posting answers
with non-codegolfing languages. Try to come up with an as short as
possible answer for ‘any’ programming language. -
Standard rules apply for your answer, so you are allowed to use
STDIN/STDOUT, functions/method with the proper parameters and
return-type, full programs. Your call. -
Default Loopholes are forbidden. - If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
Python 2, 252 249
238 212 211 213 209 bytes
n=input()
x=(n+22)/23or 1
for i in range(x):b=n/x+(n%x>i);c=r""" _V_
/(@[email protected])
/361%s163
|408717804|
5201025/
''-!-''"""%'|O'[b%2];i=0;exec"c=c.replace(`i%9`,' |oO'[i>9::2][i
オンラインで試してみてください!
- Kevin Cruijssenのおかげで9バイト節約
- Mr. Xcoderのおかげで18バイト節約
- Jonathan Frechのおかげで2バイト節約できました。