7 kyu

Xmas Tree

725 of 1,374user3879542

Description:

Complete the function that returns a christmas tree of the given height. The height is passed through to the function and the function should return a list containing each line of the tree.

XMasTree(5) should return : ['____#____', '___###___', '__#####__', '_#######_', '#########', '____#____', '____#____']
XMasTree(3) should return : ['__#__', '_###_', '#####', '__#__', '__#__']

Pad with underscores (_) so each line is the same length. Also remember the trunk/stem of the tree.

Examples

The final idea is for the tree to look like this if you decide to print each element of the list:

n = 5 will result in:

____#____              1
___###___              2
__#####__              3
_#######_              4
#########       -----> 5 - Height of Tree
____#____        1      
____#____        2 - Trunk/Stem of Tree

n = 3 will result in:

__#__                  1
_###_                  2
#####          ----->  3 - Height of Tree
__#__           1
__#__           2 - Trunk/Stem of Tree
Algorithms

Stats:

CreatedJul 5, 2016
PublishedJul 6, 2016
Warriors Trained2797
Total Skips51
Total Code Submissions3532
Total Times Completed1374
Python Completions725
JavaScript Completions500
Ruby Completions88
Go Completions110
Julia Completions10
Total Stars38
% of votes with a positive feedback rating89% of 272
Total "Very Satisfied" Votes225
Total "Somewhat Satisfied" Votes33
Total "Not Satisfied" Votes11
Ad
Contributors
  • user3879542 Avatar
  • m42p1 Avatar
  • GiacomoSorbi Avatar
  • anter69 Avatar
  • donaldsebleung Avatar
  • AcesOfGlory Avatar
  • Blind4Basics Avatar
  • stellartux Avatar
  • trashy_incel Avatar
Ad