Skip to content

homework 1#757

Open
Snezhnyy wants to merge 2 commits intorubyroidlabs:masterfrom
Snezhnyy:homework-1
Open

homework 1#757
Snezhnyy wants to merge 2 commits intorubyroidlabs:masterfrom
Snezhnyy:homework-1

Conversation

@Snezhnyy
Copy link
Copy Markdown

Фамилия Имя

Добшиков Анатолий

Email

anatoly.dobshikov@mail.ru

Номер домашнего задания

1

Ссылка на видео с демо работы

https://www.youtube.com/watch?v=K4nAUYTvlzQ

Комментарии

Мой первый треугольник Паскаля...

coef[i + 1] = 0
(i + 1).downto(1) do |j|
coef[j] = coef[j] + coef[j - 1]
end
Copy link
Copy Markdown

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]
Copy link
Copy Markdown

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|
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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|
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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: ";
Copy link
Copy Markdown

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: ";
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Contributor

@Xanderwot Xanderwot left a 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)
Copy link
Copy Markdown
Contributor

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|
Copy link
Copy Markdown
Contributor

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]
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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.

Snezhnyy and others added 2 commits March 27, 2018 23:46
Homework 1: The Magic Triangle

Pascals triangle with fix(i)es
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants