← Back to challenges

Arrow Pattern

PythonHardalgorithmsarrays

Instructions

Create a function that creates a pattern as a 2D list for a given number.

Examples

 >
 >>
 >>>
 >>
 >

arrow(3) ➞ [">", ">>", ">>>", ">>", ">"]
 >
 >>
 >>>
 >>>>
 >>>>
 >>>
 >>
 >

arrow(4) ➞ [">", ">>", ">>>", ">>>>", ">>>>", ">>>", ">>", ">"]

Notes

  • Function argument will always be a number greater than 0.
  • Odd numbers will have a single "peak" (see example #1).
  • Even numbers have two "peaks" (see example #2).
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.