-
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
Add homework-1 #770
base: master
Are you sure you want to change the base?
Add homework-1 #770
Conversation
|
||
triangle = Triangle.new(base_number, deep) | ||
|
||
triangle.show |
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.
Final newline missing.
|
||
base_number = gets.chomp.to_i | ||
|
||
puts "Введите глубину треугольника:" |
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.
end | ||
end | ||
|
||
puts "Введите начальное значение:" |
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.
end.join(" ").center(width) | ||
puts "#{i + 1}: #{string}" | ||
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.
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.
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) |
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 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.
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 |
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.
Surrounding space missing for operator -.
@deep = deep | ||
end | ||
|
||
def fact (a) |
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 put a space between a method name and the opening parenthesis.
@base_number = base_number | ||
@deep = deep | ||
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.
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| |
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.
Use 2 (not 4) spaces for indentation.
(1..a).reduce(:*) | ||
end | ||
|
||
def binomial(n,k) |
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.
Space missing after comma.
|
||
def initialize (base_number,deep) | ||
@base_number=base_number | ||
@deep=deep |
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.
Surrounding space missing for operator =.
class Triangle | ||
|
||
def initialize (base_number,deep) | ||
@base_number=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.
Surrounding space missing for operator =.
@@ -0,0 +1,45 @@ | |||
class Triangle | |||
|
|||
def initialize (base_number,deep) |
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 put a space between a method name and the opening parenthesis.
Space missing after comma.
Trailing whitespace detected.
@@ -0,0 +1,45 @@ | |||
class Triangle | |||
|
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.
@@ -0,0 +1,45 @@ | |||
class Triangle |
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.
triangle = Triangle.new(base_number, deep) | ||
|
||
triangle.show | ||
|
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.
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.
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) |
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.
@@ -0,0 +1,45 @@ | |||
class Triangle | |||
|
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.
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.
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) |
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 put a space between a method name and the opening parenthesis.
Trailing whitespace detected.
triangle = Triangle.new(base_number, deep) | ||
|
||
triangle.show | ||
|
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.
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.
Имена переменных, прям очень сложно читать все эти 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 |
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.
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 |
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.
Line is too long. [81/80]
сократил имена переменных, т.к. не влазили в допустимое значение символов в строке ln_s (изначально line_size) num_in_ln (изначально number_in_line)
Фамилия Имя
Моисеенко Алексей
Email
[email protected]
Номер домашнего задания
1
Ссылка на видео с демо работы
https://youtu.be/oQPuwp8d4_0
Комментарии
Хотел сделать ограничение на ввод глубины треугольника (в связи стем что при значениях больше 15 последний массив шире чем строка терминала и структура начинает сбиваться ), однако посчитал нецелесообразным в связи с тем, что центрирование треугольника настроено по ширине окна терминала.