Conversation
|
|
||
| triangle = Triangle.new(base_number, deep) | ||
|
|
||
| triangle.show No newline at end of file |
|
|
||
| base_number = gets.chomp.to_i | ||
|
|
||
| puts "Введите глубину треугольника:" |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
| end | ||
| end | ||
|
|
||
| puts "Введите начальное значение:" |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
| end.join(" ").center(width) | ||
| puts "#{i + 1}: #{string}" | ||
| end | ||
| end |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Space inside parentheses detected.
| end | ||
|
|
||
| def binomial(n, k) | ||
| return @base_number if n-k <= 0 || k <= 0 |
There was a problem hiding this comment.
Surrounding space missing for operator -.
| @deep = deep | ||
| end | ||
|
|
||
| def fact (a) |
There was a problem hiding this comment.
Do not put a space between a method name and the opening parenthesis.
| @base_number = base_number | ||
| @deep = deep | ||
| end | ||
|
|
Изменения согласно комментариев бота
| 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| |
There was a problem hiding this comment.
Use 2 (not 4) spaces for indentation.
| (1..a).reduce(:*) | ||
| end | ||
|
|
||
| def binomial(n,k) |
|
|
||
| def initialize (base_number,deep) | ||
| @base_number=base_number | ||
| @deep=deep |
There was a problem hiding this comment.
Surrounding space missing for operator =.
| class Triangle | ||
|
|
||
| def initialize (base_number,deep) | ||
| @base_number=base_number |
There was a problem hiding this comment.
Surrounding space missing for operator =.
| @@ -0,0 +1,45 @@ | |||
| class Triangle | |||
|
|
|||
| def initialize (base_number,deep) | |||
There was a problem hiding this comment.
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 | |||
|
|
|||
| @@ -0,0 +1,45 @@ | |||
| class Triangle | |||
| triangle = Triangle.new(base_number, deep) | ||
|
|
||
| triangle.show | ||
|
|
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
| @@ -0,0 +1,45 @@ | |||
| class Triangle | |||
|
|
|||
There was a problem hiding this comment.
Extra empty line detected at class body beginning.
| fact(n) / (fact(k) * fact(n - k)) * @base_number | ||
| end | ||
|
|
||
| def curr_str (n) |
There was a problem hiding this comment.
Do not put a space between a method name and the opening parenthesis.
| @@ -0,0 +1,43 @@ | |||
| class Triangle | |||
| def initialize (base_number, deep) | |||
There was a problem hiding this comment.
Do not put a space between a method name and the opening parenthesis.
Trailing whitespace detected.
| triangle = Triangle.new(base_number, deep) | ||
|
|
||
| triangle.show | ||
|
|
Xanderwot
left a comment
There was a problem hiding this comment.
Имена переменных, прям очень сложно читать все эти 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 |
| end | ||
|
|
||
| def binomial(line_size, number_in_line) | ||
| return @base_number if line_size - number_in_line <= 0 || number_in_line <= 0 |
сократил имена переменных, т.к. не влазили в допустимое значение символов в строке ln_s (изначально line_size) num_in_ln (изначально number_in_line)
Фамилия Имя
Моисеенко Алексей
Email
alexeymoiseenko@gmail.com
Номер домашнего задания
1
Ссылка на видео с демо работы
https://youtu.be/oQPuwp8d4_0
Комментарии
Хотел сделать ограничение на ввод глубины треугольника (в связи стем что при значениях больше 15 последний массив шире чем строка терминала и структура начинает сбиваться ), однако посчитал нецелесообразным в связи с тем, что центрирование треугольника настроено по ширине окна терминала.