-
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
implement hw 1 #761
base: master
Are you sure you want to change the base?
implement hw 1 #761
Conversation
2018/IvanKarpechanka/1/hw.rb
Outdated
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 | ||
|
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.
2018/IvanKarpechanka/1/hw.rb
Outdated
|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, ",") #элементы |
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 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.
2018/IvanKarpechanka/1/hw.rb
Outdated
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) #ветви |
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 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.
2018/IvanKarpechanka/1/hw.rb
Outdated
(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 + " ") |
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.
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.
2018/IvanKarpechanka/1/hw.rb
Outdated
gaps = (" " * (number_max_len)) #для формирования отображения в консоле | ||
help_str = "\/#{gaps}\\#{gaps}" #задание шаблона отображения ветвей дерева | ||
(0..three_len).each do |i| | ||
str = "" #для создания строки вывода на консоль каждой строчки дерева |
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.
Missing space after #.
Use only ascii symbols in comments.
2018/IvanKarpechanka/1/hw.rb
Outdated
puts "Введите базовый номер:" | ||
first_el = gets.chomp.to_i | ||
|
||
number_max_len = pascals_row(three_len, first_el).max.to_s.length #для вывода числа с нулями в начале, если его длинна меньше длинны максимального элемента |
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.
Missing space after #.
Use only ascii symbols in comments.
Line is too long. [155/80]
2018/IvanKarpechanka/1/hw.rb
Outdated
|
||
puts "Введите глубину дерева:" | ||
three_len = 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.
2018/IvanKarpechanka/1/hw.rb
Outdated
(0..row).map { |line| first_el * binom(row, line) } | ||
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.
2018/IvanKarpechanka/1/hw.rb
Outdated
end | ||
|
||
def binom(n,k) | ||
fact(n) / ( fact(k) * fact(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 inside parentheses detected.
Surrounding space missing for operator -.
2018/IvanKarpechanka/1/hw.rb
Outdated
(1..n).inject(1, :*) | ||
end | ||
|
||
def binom(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.
2018/IvanKarpechanka/1/hw.rb
Outdated
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 |
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.
2018/IvanKarpechanka/1/hw.rb
Outdated
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, ',') |
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 to_s over string interpolation.
Line is too long. [102/80]
2018/IvanKarpechanka/1/hw.rb
Outdated
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) |
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 to_s over string interpolation.
Line is too long. [88/80]
2018/IvanKarpechanka/1/hw.rb
Outdated
(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 + ' ') |
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 1) spaces for indentation.
2018/IvanKarpechanka/1/hw.rb
Outdated
# 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)) |
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.
Don't use parentheses around a variable.
2018/IvanKarpechanka/1/hw.rb
Outdated
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 |
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. [109/80]
2018/IvanKarpechanka/1/hw.rb
Outdated
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')}" |
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 to_s over string interpolation.
2018/IvanKarpechanka/1/hw.rb
Outdated
(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 + ' ') |
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 1) spaces for indentation.
Tab detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
puts 'Введите базовый номер:' | ||
first_el = gets.chomp.to_i | ||
|
||
# to output a number with zeros in the beginning if its |
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.
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, ',') |
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.
Inconsistent indentation detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
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') |
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.
Inconsistent indentation detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
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) |
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.
Inconsistent indentation detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
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 |
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.
Inconsistent indentation detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
(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 + ' ') |
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 1) spaces for indentation.
Tab detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
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| |
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.
Inconsistent indentation detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
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 |
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 1) spaces for indentation.
Tab detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
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 |
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 0) spaces for indentation.
2018/IvanKarpechanka/1/hw.rb
Outdated
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) |
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.
Inconsistent indentation detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
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 |
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.
Inconsistent indentation detected.
2018/IvanKarpechanka/1/hw.rb
Outdated
help_str = "\/#{gaps}\\#{gaps}" | ||
(0..three_len).each do |i| | ||
str = '' | ||
pascals_row(i, first_el).each do |elem| |
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.
Inconsistent indentation detected.
gaps = (' ' * number_max_len) | ||
help_str = "\/#{gaps}\\#{gaps}" | ||
(0..three_len).each do |i| | ||
str = '' |
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.
2 пробела
console_len = `tput cols`.to_i | ||
gaps = (' ' * number_max_len) | ||
help_str = "\/#{gaps}\\#{gaps}" | ||
(0..three_len).each do |i| |
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.
three_len.times do |tree_level|
@@ -0,0 +1,30 @@ | |||
def fact(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.
Используй более дружелюбные переменные, чтобы можно было читать код легко, а не гадать что такое 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 |
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.
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') |
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.
аналогично с help1
Фамилия Имя
Карпеченко Иван
Email
[email protected]
Номер домашнего задания
1
Ссылка на видео с демо работы
https://www.youtube.com/watch?v=Kcgrlq_8YaY
Комментарии
Нету