9.1. ASCII Pyramid
Task
Create a function which prints an ASCII Pyramid. The function must take the height of the pyramid as parameter.
If you call the function with 5 as parameter we should get the following pyramid:
*
***
*****
*******
*********
Tips
Standard library packages
The package fmt contains various print functions.
Standard library functions
With fmt.Print you can print strings:
// print space
fmt.Print(" ")
// print newline
fmt.Print("\n")
Calculate number of spaces and stars
On each line you have to print the appropriate number of spaces and stars:
- spaces:
height - lineNumber - stars:
lineNumber * 2 - 1
Solution
https://github.com/acend/go-basics-training-examples/blob/master/ascii-pyramid/main.go
Last modified May 29, 2024: Merge pull request #205 from acend/renovate/actions-checkout-digest (cc47d9a)