Most people are familiar with the trope about counting sheep to fall asleep. There's a herd of sheep, some of them jumping over a fence, and you count the sheep as they jump. Supposedly, this helps quiet your mind and gets you into a sleep-like state so that you'll fall asleep.
Here's an ASCII sheep facing to the right, waiting to be counted:
'00^>
||
Here's an ASCII sheep jumping over a fence:
'00^>
/\
++
Here's one facing to the left, having already been counted:
<^00'
||
The Challenge
Given two input integers, n
and m
, with n > 2
describing how many sheep total, and m > 0
saying how many sheep have already been counted, output an ASCII art representation of counting sheep to fall asleep.
Now for the twist:
- Due to the size of the pens the sheep are in, the top row can only hold a maximum of
10
sheep, not counting the currently jumping sheep which must also always be in the top row. - The subsequent rows cannot have the sheep outside their respective pens (you can't have more sheep on the left in the second row than you do in the first row, and same for the right).
- If there are
11
or more total sheep, the top row must have10
plus the jumping sheep in it. - Leading/trailing whitespace, and whitespace between the sheep doesn't matter, so long as:
- There is a minimum of one whitespace character between sheep
- All the characters line up appropriately.
So long as these rules are met, the actual arrangement of the sheep is up to your implementation.
Examples
For example, here is n=3
and m=1
, the simplest case.
'00^>
'00^> /\ <^00'
|| ++ ||
Here is n=11
and m=6
, the most sheep that can fit on one horizontal line.
'00^>
'00^> '00^> '00^> '00^> /\ <^00' <^00' <^00' <^00' <^00' <^00'
|| || || || ++ || || || || || ||
Here's a different example of that, with n=11
and m=1
'00^>
'00^> '00^> '00^> '00^> '00^> '00^> '00^> '00^> '00^> /\ <^00'
|| || || || || || || || || ++ ||
A bigger example with n=30
and m=12
'00^>
'00^> '00^> '00^> '00^> '00^> '00^> '00^> '00^> /\ <^00' <^00'
|| || || || || || || || ++ || ||
'00^> '00^> '00^> '00^> '00^> '00^> '00^> '00^> <^00' <^00'
|| || || || || || || || || ||
'00^> <^00' <^00'
|| || ||
<^00' <^00'
|| ||
<^00' <^00'
|| ||
<^00' <^00'
|| ||
Here's an example with n=17
and m=2
'00^>
'00^> '00^> '00^> '00^> '00^> '00^> '00^> '00^> /\ <^00' <^00'
|| || || || || || || || ++ || ||
'00^> '00^> '00^> '00^> '00^> '00^>
|| || || || || ||
Here's an example with n=19
and m=3
'00^>
'00^> '00^> '00^> '00^> '00^> '00^> '00^> /\ <^00' <^00' <^00'
|| || || || || || || ++ || || ||
'00^> '00^> '00^> '00^> '00^> '00^> '00^>
|| || || || || || ||
'00^>
||
Note that all of these are examples. For the last one, you may wind up creating a vertical array of sheep on the right-hand side, which will allow the left hand side to fit onto two rows instead. Or maybe a 2x2 square of sheep on the right-hand side, which would also fit the left-hand side sheep onto two rows. Etc.
I/O and Rules
- Input can be taken in any reasonable format and by any convenient method.
- Leading/trailing newlines or other whitespace are optional, provided that the characters line up appropriately.
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- Output can be to the console, returned as a list of strings, returned as a single string, etc.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
n=11
andm=9
\$\endgroup\$n=11
such that0<m<=10
. This forces you to have all the sheep on the top row and a dynamic number of sheep on the left (n-1-m
) and right (m
) of the fence and cannot use fixed pen sizes. \$\endgroup\$