Skip to content

Commit 3c9d5d9

Browse files
committed
Printed the n*n Squares
1 parent 816e696 commit 3c9d5d9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

exercises/print_square.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# The print_line method is here to help you.
1515
# Conceptually, it prints out a row of "count" *'s. Run it yourself to
16-
# see how it works. Experiment with different inputs.
16+
# see how it works. Experiment with xRails params explained?different inputs.
1717
def print_line(count)
1818
(1..count).each do |i| # or, equivalently, for i in (1..count)
1919
print "*" # This prints a single "*"
@@ -25,9 +25,12 @@ def print_line(count)
2525
# We can call methods we've defined ourselves. In this case, we want
2626
# to call the print_line method we've defined to help us print out a square.
2727
def print_square(dimension)
28+
2829
(1..dimension).each do |i| # or, equivalently, for i in (1..dimension)
29-
print_line(2) # Fill in the blank, here.
30+
print_line(dimension) # Recursion. Kind of. I called the print_line method on the print_square method using the print_square arguement. I don't know what its called. It just works ;).
31+
print "\n"
3032
end
33+
3134
end
3235

3336
# There are no rumble strips this time. It's up to you to decide whether

0 commit comments

Comments
 (0)