-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement homework 1 #774
base: master
Are you sure you want to change the base?
implement homework 1 #774
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
print 'Enter depth: ' | ||
depth = gets.to_i | ||
print 'Enter basic number: ' | ||
base_number = gets.to_i | ||
array = [] | ||
(1..depth).each do |i| | ||
array[i] = 0 | ||
end | ||
z = depth | ||
array[0] = base_number | ||
(1..depth).each do |j| | ||
(1..j).reverse_each do |i| | ||
if(i==j) | ||
x = " "*z | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. end at 15, 6 is not aligned with if at 13, 4. |
||
print "#{x}#{array[i - 1]} " | ||
array[i] = array[i - 1] + array[i] | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. end at 18, 6 is not aligned with (1..j).reverse_each do |i| at 12, 2. |
||
z-=1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surrounding space missing for operator -=. |
||
puts | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 (not -2) spaces for indentation.
Space after keyword if is missing.
Surrounding space missing for operator ==.