nanenj icon

[Ruby] Growing Stars - Simpler Solution

nanenj | PRO | 06/18/17 04:43:11 PM UTC | 0 ⭐ | 292 👁️ | Never ⏰ | []
Ruby |

230 B

|

None

|

0 👍

/

0 👎

def display_stars(count)
  puts "* "*count
end
 
def display_growing_stars(times)
  [*1..times].each { |t| display_stars(t) }
end
 
irb(main):001:0> display_growing_stars(5)
*
* *
* * *
* * * *
* * * * *
=> [1, 2, 3, 4, 5]

Comments