Advertisement
nanenj

[Ruby] Growing Stars - Simpler Solution

Jun 18th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.23 KB | None | 0 0
  1. def display_stars(count)
  2.   puts "* "*count
  3. end
  4.  
  5. def display_growing_stars(times)
  6.   [*1..times].each { |t| display_stars(t) }
  7. end
  8.  
  9. irb(main):001:0> display_growing_stars(5)
  10. *
  11. * *
  12. * * *
  13. * * * *
  14. * * * * *
  15. => [1, 2, 3, 4, 5]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement