When we think about Ladybugs, we usually think of a red or dark orange bug with black spots. Although this isn't necessary true, since there are also black with red/orange spotted ladybugs, or ladybugs without spots at all, we mainly picture ladybugs something like this Asian Ladybug:
Another thing to note is that the spots on the ladybugs are almost always symmetric. And that is where this challenge comes in.
Given an integer
>= 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.
Here is the default ladybug layout:
_V_ /(@I@)\ / | \ | | | \ | / ''-!-''
n=0, we output the ladybug above as is.
n is larger than zero, we either fill in the spaces of the ASCII-art bug with a lowercase
o, or replace the
| in the center with a capital
O. The goal is to make
n changes to the 'empty' ladybug(s), while still producing a symmetric output (per ladybug), and outputting as few ladybugs as possible.
So valid outputs for
_V_ /(@I@)\ / O \ | | | \ | / ''-!-'' _V_ /(@I@)\ / | \ | O | \ | / ''-!-'' _V_ /(@I@)\ / | \ | | | \ O / ''-!-''
But this would be invalid:
_V_ /(@I@)\ / | \ | o | | \ | / ''-!-''
Valid outputs for
_V_ /(@I@)\ / O \ | O | \ | / ''-!-'' _V_ /(@I@)\ / O \ | | | \ O / ''-!-'' _V_ /(@I@)\ / o|o \ | | | \ | / ''-!-'' _V_ /(@I@)\ / | \ | o | o | \ | / ''-!-'' etc. There are a lot of possible outputs.
n that isn't possible to fit into a single ladybug anymore is
n=24. In which case you'll have to divide it as evenly as possible into two ladybugs (you can choose whether to output them next to each other, or under one another - with optionally one space or one new-line in between them). For example:
_V_ _V_ /(@I@)\ /(@I@)\ /o o|o o\ /o o|o o\ |o o | o o||o o | o o| \o o|o o/ \o o|o o/ ''-!-'' ''-!-''
_V_ /(@I@)\ /ooo|ooo\ | | | \ooo|ooo/ ''-!-'' _V_ /(@I@)\ /ooo|ooo\ | | | \ooo|ooo/ ''-!-''
nwill be in the range of
- 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
- Since the goal is to have
nchanges AND as few ladybugs as possible, you will start using more than one ladybug when above
n=23. The layout of these ladybugs doesn't necessary have to be the same. In fact, this isn't even possible for some inputs, like
n=50to 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.
n=50, keeping the last two rules in mind, this would be a valid possible output (where the first bug has 16 spots, and the other two have 17):
_V_ _V_ _V_ /(@I@)\ /(@I@)\ /(@I@)\ /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.