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

implement hw 1 #761

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

implement hw 1 #761

wants to merge 12 commits into from

Conversation

ivkarpechenko
Copy link

@ivkarpechenko ivkarpechenko commented Feb 18, 2018

Фамилия Имя

Карпеченко Иван

Email

[email protected]

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

1

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

https://www.youtube.com/watch?v=Kcgrlq_8YaY

Комментарии

Нету

puts "#{" " * three_len.to_s.length}" + (help_str * i).chomp(gaps).center(console_len) #ветви
puts "#{i.to_s.rjust(three_len.to_s.length, '0')}" + str.chomp(gaps + " ").center(console_len, ",") #элементы
end

Choose a reason for hiding this comment

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

Trailing whitespace detected.

|elem| str += elem.to_s.rjust(number_max_len, '0') + (gaps + " ")
end
puts "#{" " * three_len.to_s.length}" + (help_str * i).chomp(gaps).center(console_len) #ветви
puts "#{i.to_s.rjust(three_len.to_s.length, '0')}" + str.chomp(gaps + " ").center(console_len, ",") #элементы

Choose a reason for hiding this comment

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

Prefer to_s over string interpolation.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Line is too long. [112/80]
Missing space after #.
Use only ascii symbols in comments.

pascals_row(i, first_el).each do
|elem| str += elem.to_s.rjust(number_max_len, '0') + (gaps + " ")
end
puts "#{" " * three_len.to_s.length}" + (help_str * i).chomp(gaps).center(console_len) #ветви

Choose a reason for hiding this comment

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

Prefer to_s over string interpolation.
Prefer single-quoted strings inside interpolations.
Line is too long. [95/80]
Missing space after #.
Use only ascii symbols in comments.

(0..three_len).each do |i|
str = "" #для создания строки вывода на консоль каждой строчки дерева
pascals_row(i, first_el).each do
|elem| str += elem.to_s.rjust(number_max_len, '0') + (gaps + " ")

Choose a reason for hiding this comment

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

Block argument expression is not on the same line as the block start.
Prefer single-quoted strings when you don't need string interpolation or special symbols.

gaps = (" " * (number_max_len)) #для формирования отображения в консоле
help_str = "\/#{gaps}\\#{gaps}" #задание шаблона отображения ветвей дерева
(0..three_len).each do |i|
str = "" #для создания строки вывода на консоль каждой строчки дерева

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.
Missing space after #.
Use only ascii symbols in comments.

puts "Введите базовый номер:"
first_el = gets.chomp.to_i

number_max_len = pascals_row(three_len, first_el).max.to_s.length #для вывода числа с нулями в начале, если его длинна меньше длинны максимального элемента

Choose a reason for hiding this comment

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

Missing space after #.
Use only ascii symbols in comments.
Line is too long. [155/80]


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

(0..row).map { |line| first_el * binom(row, line) }
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

def binom(n,k)
fact(n) / ( fact(k) * fact(n-k) )

Choose a reason for hiding this comment

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

Space inside parentheses detected.
Surrounding space missing for operator -.

(1..n).inject(1, :*)
end

def binom(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.

end
puts "#{' ' * three_len.to_s.length}" + (help_str * i).chomp(gaps).center(console_len)
puts "#{i.to_s.rjust(three_len.to_s.length, '0')}" + str.chomp(gaps + ' ').center(console_len, ',')
end

Choose a reason for hiding this comment

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

Final newline missing.

str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')
end
puts "#{' ' * three_len.to_s.length}" + (help_str * i).chomp(gaps).center(console_len)
puts "#{i.to_s.rjust(three_len.to_s.length, '0')}" + str.chomp(gaps + ' ').center(console_len, ',')

Choose a reason for hiding this comment

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

Prefer to_s over string interpolation.
Line is too long. [102/80]

pascals_row(i, first_el).each do |elem|
str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')
end
puts "#{' ' * three_len.to_s.length}" + (help_str * i).chomp(gaps).center(console_len)

Choose a reason for hiding this comment

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

Prefer to_s over string interpolation.
Line is too long. [88/80]

(0..three_len).each do |i|
str = '' # to create an output line on the console of each line of the tree
pascals_row(i, first_el).each do |elem|
str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')

Choose a reason for hiding this comment

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

Use 2 (not 1) spaces for indentation.

# to output a number with zeros in the beginning if its length is less than the length of the maximum element
number_max_len = pascals_row(three_len, first_el).max.to_s.length
console_len = 160
gaps = (' ' * (number_max_len))

Choose a reason for hiding this comment

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

Don't use parentheses around a variable.

puts 'Введите базовый номер:'
first_el = gets.chomp.to_i

# to output a number with zeros in the beginning if its length is less than the length of the maximum element

Choose a reason for hiding this comment

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

Line is too long. [109/80]

help1 = "#{' ' * three_len.to_s.length}"
puts help1 + (help_str * i).chomp(gaps).center(console_len)

help2 = "#{i.to_s.rjust(three_len.to_s.length, '0')}"

Choose a reason for hiding this comment

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

Prefer to_s over string interpolation.

(0..three_len).each do |i|
str = '' # to create an output line on the console of each line of the tree
pascals_row(i, first_el).each do |elem|
str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')

Choose a reason for hiding this comment

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

Use 2 (not 1) spaces for indentation.
Tab detected.

puts 'Введите базовый номер:'
first_el = gets.chomp.to_i

# to output a number with zeros in the beginning if its

Choose a reason for hiding this comment

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

Trailing whitespace detected.

help1 = ' ' * three_len.to_s.length
puts help1 + (help_str * i).chomp(gaps).center(console_len)
help2 = i.to_s.rjust(three_len.to_s.length, '0')
puts help2 + str.chomp(gaps + ' ').center(console_len, ',')

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

end
help1 = ' ' * three_len.to_s.length
puts help1 + (help_str * i).chomp(gaps).center(console_len)
help2 = i.to_s.rjust(three_len.to_s.length, '0')

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')
end
help1 = ' ' * three_len.to_s.length
puts help1 + (help_str * i).chomp(gaps).center(console_len)

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

pascals_row(i, first_el).each do |elem|
str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')
end
help1 = ' ' * three_len.to_s.length

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

(0..three_len).each do |i|
str = '' # to create an output line on the console of each line of the tree
pascals_row(i, first_el).each do |elem|
str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')

Choose a reason for hiding this comment

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

Use 2 (not 1) spaces for indentation.
Tab detected.

help_str = "\/#{gaps}\\#{gaps}" # Specifying a Tree Display Template
(0..three_len).each do |i|
str = '' # to create an output line on the console of each line of the tree
pascals_row(i, first_el).each do |elem|

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

gaps = (' ' * number_max_len)
help_str = "\/#{gaps}\\#{gaps}" # Specifying a Tree Display Template
(0..three_len).each do |i|
str = '' # to create an output line on the console of each line of the tree

Choose a reason for hiding this comment

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

Use 2 (not 1) spaces for indentation.
Tab detected.

gaps = (' ' * number_max_len)
help_str = "\/#{gaps}\\#{gaps}" # Specifying a Tree Display Template
(0..three_len).each do |i|
str = '' # to create an output line on the console of each line of the tree

Choose a reason for hiding this comment

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

Use 2 (not 0) spaces for indentation.

str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')
end
help1 = ' ' * three_len.to_s.length
puts help1 + (help_str * i).chomp(gaps).center(console_len)

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

pascals_row(i, first_el).each do |elem|
str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')
end
help1 = ' ' * three_len.to_s.length

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

help_str = "\/#{gaps}\\#{gaps}"
(0..three_len).each do |i|
str = ''
pascals_row(i, first_el).each do |elem|

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

gaps = (' ' * number_max_len)
help_str = "\/#{gaps}\\#{gaps}"
(0..three_len).each do |i|
str = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

2 пробела

console_len = `tput cols`.to_i
gaps = (' ' * number_max_len)
help_str = "\/#{gaps}\\#{gaps}"
(0..three_len).each 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.

three_len.times do |tree_level|

@@ -0,0 +1,30 @@
def fact(n)
Copy link
Contributor

Choose a reason for hiding this comment

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

Используй более дружелюбные переменные, чтобы можно было читать код легко, а не гадать что такое n, k или j

pascals_row(i, first_el).each do |elem|
str += elem.to_s.rjust(number_max_len, '0') + (gaps + ' ')
end
help1 = ' ' * three_len.to_s.length
Copy link
Contributor

Choose a reason for hiding this comment

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

help1 прям очень плохо. Я уверен ты можешь лучше.

end
help1 = ' ' * three_len.to_s.length
puts help1 + (help_str * i).chomp(gaps).center(console_len)
help2 = i.to_s.rjust(three_len.to_s.length, '0')
Copy link
Contributor

Choose a reason for hiding this comment

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

аналогично с help1

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