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

Add homework-1 #770

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

Conversation

alexeymoiseenko
Copy link

@alexeymoiseenko alexeymoiseenko commented Feb 20, 2018

Фамилия Имя

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

Email

[email protected]

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

1

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

https://youtu.be/oQPuwp8d4_0

Комментарии

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


triangle = Triangle.new(base_number, deep)

triangle.show

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

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

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

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

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)

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

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

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)

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

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|

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)

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

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

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)

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

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

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

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

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)

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

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)

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)

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

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

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

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