6 kyu
Hollow Triangle
231 of 402user3879542
Description:
Create a function that takes a positive integer n
and returns a hollow triangle of the correct height.
The height n
is passed through to the function and the function should return a list containing each line of the hollow triangle.
When n = 6,
Should return :
["_____#_____",
"____#_#____",
"___#___#___",
"__#_____#__",
"_#_______#_",
"###########"]
When n = 9,
Should return :
["________#________",
"_______#_#_______",
"______#___#______",
"_____#_____#_____",
"____#_______#____",
"___#_________#___",
"__#___________#__",
"_#_____________#_",
"#################"]
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
n = 6 will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
n = 9 will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
Pad empty spaces with underscores (_
) so each line is the same length.
Good luck and have fun coding!
ASCII Art
Fundamentals
Similar Kata:
Stats:
Created | Jul 10, 2016 |
Published | Jul 10, 2016 |
Warriors Trained | 653 |
Total Skips | 22 |
Total Code Submissions | 956 |
Total Times Completed | 402 |
Python Completions | 231 |
Ruby Completions | 42 |
JavaScript Completions | 156 |
Total Stars | 22 |
% of votes with a positive feedback rating | 94% of 124 |
Total "Very Satisfied" Votes | 110 |
Total "Somewhat Satisfied" Votes | 13 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 18 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |