🔻
Inverse Word Pyramid
Week 41
If you remember back to previous challenges like Right-Align and Toggle Case, we were looking at how to format strings, in preparation for a future challenge
Let's have a look at another such string formatting challenge this week - how to format text into a pyramid/triangle shape
You should create a function that takes 5 parameters:
- sentence: the string to format
- initialPadding: the starting left padding for each line
- paddingChange: the amount the padding changes each line
- leftWordDec: the reduction in the number of words at the start of the sentence each line
- rightWordDec: the reduction in the number of words at the end of the sentence each line
For this challenge, you can assume each word is separated by a single space - there will be no punctuation symbols etc
Let's look at some example function calls, with explanations underneath too:
For your program, you should paste the output of multiple function calls one after another - for example, suppose our function calls were:
Then our output would be:
Note: new lines separating each function call are allowed in the output - any right (trailing) spaces will be trimmed when the site marks the answer, so whether you keep them or not is not important
For your answer, you should use the following sentence with the 6 functions calls below:
Good luck - when you think you have it, paste your answer below:
Hints
Hints will be released at the start of each of the following days - e.g. the start of day 3 is 48 hours after the challenge starts
| Release Day | Hint |
|---|---|
| 2 |