File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,29 @@ def print_pyramid(height)
2525 # Suggestion: you can call print_triangle to print out the first, "upward"
2626 # half of the pyramid. You'll have to write code to print out the second,
2727 # "downward" half of the pyramid.
28+
29+ print_triangle ( height )
30+ height . downto ( 1 ) do |i | # or, equivalently, reverse the range from height to 1
31+ print_line ( i ) # I called the print_line method to repeat the same process as in print_triangle.rb
32+
33+ end
34+
2835end
2936
3037if __FILE__ == $PROGRAM_NAME
3138 # I'd advise putting some sanity checks here.
3239 # How else will you be sure your code does what you think it does?
40+ print_pyramid ( 1 )
41+
42+ print "\n \n \n " # This is here to make the separation between pyramids clearer
43+
44+ print_pyramid ( 2 )
45+
46+ print "\n \n \n " # This is here to make the separation between pyramids clearer
47+
48+ print_pyramid ( 3 )
49+
50+ print "\n \n \n " # This is here to make the separation between pyramids clearer
51+
52+ print_pyramid ( 10 )
3353end
You can’t perform that action at this time.
0 commit comments