-
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
homework 1 #757
base: master
Are you sure you want to change the base?
homework 1 #757
Conversation
coef[i + 1] = 0 | ||
(i + 1).downto(1) do |j| | ||
coef[j] = coef[j] + coef[j - 1] | ||
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.
Tab detected.
print "#{i}:"; puts coef.join(" ").center(cols) | ||
coef[i + 1] = 0 | ||
(i + 1).downto(1) do |j| | ||
coef[j] = coef[j] + coef[j - 1] |
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.
Tab detected.
Use 2 (not 1) spaces for indentation.
0.upto(tree_depth - 1) do |i| | ||
print "#{i}:"; puts coef.join(" ").center(cols) | ||
coef[i + 1] = 0 | ||
(i + 1).downto(1) do |j| |
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.
Tab detected.
Inconsistent indentation detected.
Trailing whitespace detected.
coef = [base_number] | ||
cols = %x(/usr/bin/tput cols).chomp.to_i - 3 | ||
0.upto(tree_depth - 1) do |i| | ||
print "#{i}:"; puts coef.join(" ").center(cols) |
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.
Do not use semicolons to terminate expressions.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
#tree create | ||
coef = [base_number] | ||
cols = %x(/usr/bin/tput cols).chomp.to_i - 3 | ||
0.upto(tree_depth - 1) do |i| |
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.
Trailing whitespace detected.
tree_depth = gets.chomp.to_i | ||
print "Input base number: "; | ||
base_number = gets.chomp.to_i | ||
#checking values |
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.
Missing space after #.
#values input | ||
print "Input tree depth: "; | ||
tree_depth = gets.chomp.to_i | ||
print "Input base number: "; |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Do not use semicolons to terminate expressions.
@@ -0,0 +1,21 @@ | |||
#Program draws pascal's triangle with the specified depth in the console | |||
#values input | |||
print "Input tree depth: "; |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Do not use semicolons to terminate expressions.
@@ -0,0 +1,21 @@ | |||
#Program draws pascal's triangle with the specified depth in the console | |||
#values input |
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.
Missing space after #.
@@ -0,0 +1,21 @@ | |||
#Program draws pascal's triangle with the specified depth in the console |
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.
Missing space after #.
cols = `/usr/bin/tput cols`.chomp.to_i | ||
spaces = ' ' * (tree_depth / 4 > 0 ? tree_depth / 4 : 1) | ||
0.upto(tree_depth - 1) do |i| | ||
printf("%03d:", i) |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
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.
В целом нормально, но нужно писать прям очень читаемый код ;)
# tree create | ||
coef = [base_number] | ||
cols = `/usr/bin/tput cols`.chomp.to_i | ||
spaces = ' ' * (tree_depth / 4 > 0 ? tree_depth / 4 : 1) |
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.
вынеси 4 в константу и назови её как-то более дружелюбно
coef = [base_number] | ||
cols = `/usr/bin/tput cols`.chomp.to_i | ||
spaces = ' ' * (tree_depth / 4 > 0 ? tree_depth / 4 : 1) | ||
0.upto(tree_depth - 1) do |i| |
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.
(0...tree_depth).each do |level|
puts coef.join(spaces).center(cols) | ||
coef.push(0) | ||
(i + 1).downto(1) do |j| | ||
coef[j] += coef[j - 1] |
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.
имена переменных j, i, n и прочее читать прям очень не удобно
coef[column] += coef[column - 1] | ||
end | ||
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.
1 trailing blank lines detected.
Homework 1: The Magic Triangle Pascals triangle with fix(i)es
Фамилия Имя
Добшиков Анатолий
Email
[email protected]
Номер домашнего задания
1
Ссылка на видео с демо работы
https://www.youtube.com/watch?v=K4nAUYTvlzQ
Комментарии
Мой первый треугольник Паскаля...