36
1
Backstory
Disclaimer: May contain made up information about kangaroos.
Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry.
In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is constantly requires nourishment. We can represent a stage 1 kangaroo's activity pattern like this.
o
In stage 2, the kangaroo can make small jumps, but not more than 2 before it gets hungry. We can represent a stage 2 kangaroo's activity pattern like this.
o o
o o o
After stage 2 the kangaroo improves quickly. In each subsequent stage, the kangaroo can jump a bit higher (1 unit in the graphical representation) and twice as many times. For example, a stage 3 kangaroo's activity pattern looks like this.
o o o o
o o o o o o o o
o o o o o
For stage n, the activity pattern consists of 2n-1 V-shaped jumps of height n.
For example, for stage 4, there are 8 jumps of height 4.
o o o o o o o o
o o o o o o o o o o o o o o o o
o o o o o o o o o o o o o o o o
o o o o o o o o o
Task
Write a full program or a function that takes a positive integer n as input and prints or returns the ASCII art representation of a stage n kangaroo's activity pattern.
Surrounding whitespace and ANSI escape codes are allowed, as long as the pattern looks exactly as depicted above.
If you choose a function that returns the output, it must return a single string or character array that displays the proper output when printed. Returning an array of strings is not allowed.
You can use any printable, non-whitespace character instead of o
, as long as it is consistent within the activity pattern and across all patterns in your answer.
This is code-golf; may the shortest answer in bytes win!
I need some clarification. You said you can use any character to represent
o
. Can you also use any character to represent the spaces (as long as they are different?)? – Kodos Johnson – 2017-01-23T01:09:05.0071The spaces have to be blank. You can use actual spaces or you can use control codes to move the cursor around, but you cannot use printable non-space characters. – Dennis – 2017-01-23T01:24:57.703
1http://codegolf.stackexchange.com/questions/96379/compute-the-kangaroo-sequence - Related. – Magic Octopus Urn – 2017-01-23T17:59:56.467