Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

homework 1 #757

wants to merge 2 commits into from

Conversation

Snezhnyy
Copy link

Фамилия Имя

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

Email

[email protected]

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

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

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]

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|

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)

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|

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

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: ";

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: ";

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

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

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)

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
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
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
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
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

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