DEV Community

Discussion on: Daily Challenge #52 - Building a Pyramid

Collapse
 
thepeoplesbourgeois profile image
Josh

Since this is pretty much the top half of a string diamond I took my answer from that challenge and used just the first half of the code but it isn't working like expected, can someone tell me where I went wrong? 😥

Ruby:

def riamond_i_mean_ryramid(karat)
  unless karat.odd? && karat > 0
    raise ArgumentError.new("You want a #{karat} karat ~~diamond~~ pyramid? That's crazy!")
  end
  cut = 1
  layers = []
  until cut > karat
    layers.push(("*" * cut).center(karat))