...

/

Solution: Printing a Half Diamond

Solution: Printing a Half Diamond

Go over the implementation of printing the half diamond shape.

Courtney’s version

Press + to interact
count = 0
8.times do
count += 1 # this is equivalent to count = count + 1
hashes = "#" * count
puts hashes
end
count = 8
8.times do
count -= 1
hashes = "#" * count
puts hashes
end

Explanation

Courtney’s version code loops 16 times, (two loops of 8 iterations each) , but prints out 15 lines of the half diamond. This is because in ...