Skip to content

Add homework-1#770

Open
alexeymoiseenko wants to merge 10 commits intorubyroidlabs:masterfrom
alexeymoiseenko:homework-1
Open

Add homework-1#770
alexeymoiseenko wants to merge 10 commits intorubyroidlabs:masterfrom
alexeymoiseenko:homework-1

Conversation

@alexeymoiseenko
Copy link
Copy Markdown

@alexeymoiseenko alexeymoiseenko commented Feb 20, 2018

Фамилия Имя

Моисеенко Алексей

Email

alexeymoiseenko@gmail.com

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

1

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

https://youtu.be/oQPuwp8d4_0

Комментарии

Хотел сделать ограничение на ввод глубины треугольника (в связи стем что при значениях больше 15 последний массив шире чем строка терминала и структура начинает сбиваться ), однако посчитал нецелесообразным в связи с тем, что центрирование треугольника настроено по ширине окна терминала.


triangle = Triangle.new(base_number, deep)

triangle.show No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.


base_number = gets.chomp.to_i

puts "Введите глубину треугольника:"
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.

end
end

puts "Введите начальное значение:"
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.

end.join(" ").center(width)
puts "#{i + 1}: #{string}"
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.

end at 32, 1 is not aligned with def at 22, 2.

el.to_s.center(max_el_size)
end.join(" ").center(width)
puts "#{i + 1}: #{string}"
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.

end at 31, 2 is not aligned with @deep.times do |i| at 26, 4.

fact(n) / ( fact(k) * fact( n - k ) ) * @base_number
end

def curr_str (n)
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 put a space between a method name and the opening parenthesis.


def binomial(n, k)
return @base_number if n-k <= 0 || k <= 0
fact(n) / ( fact(k) * fact( n - k ) ) * @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.

Space inside parentheses detected.

end

def binomial(n, k)
return @base_number if n-k <= 0 || k <= 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surrounding space missing for operator -.

@deep = deep
end

def fact (a)
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 put a space between a method name and the opening parenthesis.

@base_number = base_number
@deep = deep
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.

Trailing whitespace detected.

Изменения согласно комментариев бота
max_el_size = max_row.max.to_s.size
width = [`tput cols`.to_i,100].max
@deep.times do |i|
string = curr_str(i).map do |el|
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 2 (not 4) spaces for indentation.

(1..a).reduce(:*)
end

def binomial(n,k)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma.


def initialize (base_number,deep)
@base_number=base_number
@deep=deep
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surrounding space missing for operator =.

class Triangle

def initialize (base_number,deep)
@base_number=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.

Surrounding space missing for operator =.

@@ -0,0 +1,45 @@
class Triangle

def initialize (base_number,deep)
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 put a space between a method name and the opening parenthesis.
Space missing after comma.
Trailing whitespace detected.

@@ -0,0 +1,45 @@
class Triangle

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.

@@ -0,0 +1,45 @@
class Triangle
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.

triangle = Triangle.new(base_number, deep)

triangle.show

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.
Trailing whitespace detected.

string = curr_str(i).map do |el|
el.to_s.center(max_el_size)
end.join(" ").center(width)
puts "#{i+1}: #{string}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surrounding space missing for operator +.

@deep.times do |i|
string = curr_str(i).map do |el|
el.to_s.center(max_el_size)
end.join(" ").center(width)
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.

@@ -0,0 +1,45 @@
class Triangle

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at class body beginning.

fact(n) / (fact(k) * fact(n - k)) * @base_number
end

def curr_str (n)
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 put a space between a method name and the opening parenthesis.

@@ -0,0 +1,43 @@
class Triangle
def initialize (base_number, deep)
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 put a space between a method name and the opening parenthesis.
Trailing whitespace detected.

triangle = Triangle.new(base_number, deep)

triangle.show

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.

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.

Имена переменных, прям очень сложно читать все эти n, k, j, a и прочее. Назови все более понятно.


def binomial(line_size, number_in_line)
return @base_number if line_size - number_in_line <= 0 || number_in_line <= 0
fact(line_size) / (fact(number_in_line) * fact(line_size - number_in_line)) * @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.

Line is too long. [94/80]

end

def binomial(line_size, number_in_line)
return @base_number if line_size - number_in_line <= 0 || number_in_line <= 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [81/80]

сократил имена переменных, т.к. не влазили в допустимое значение символов в строке 
ln_s (изначально line_size)
num_in_ln (изначально number_in_line)
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