Skip to content

Conversation

@vshkrabkov
Copy link

Фамилия Имя

Шкрабков Владислав

Email

vlad.shkrabkov@gmail.com

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

1

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

https://youtu.be/AJvJDC_d7ag

Комментарии

Делал сразу 3 lvl. Алгоритм создания и вывода похож на всех трех уровнях, только добавляются какие-то доп условия на каждом уровне.

basic_val = gets.chomp.to_i
pasc_tri = [[basic_val]]

(1..(deep - 1)).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.

либо (deep - 1).times do
либо (1...deep).each do

Copy link
Contributor

Choose a reason for hiding this comment

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

Используй более читаемые переменные вместо i, j, m и прочего. Ниже тоже.


(1..(deep - 1)).each do |i|
ar = []
(0..i).each do |j|
Copy link
Contributor

Choose a reason for hiding this comment

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

times

require 'io/console'
size = IO.console.winsize

(0..(deep - 1)).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.

аналогично выше.

(0..(deep - 1)).each do |i|
str = ''
print "#{i}:"
(0..i).each do |j|
Copy link
Contributor

Choose a reason for hiding this comment

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

times

(0..i).each do |j|
str += (pasc_tri[i][j].to_s + (' ' * (size[1] / (deep * 2))))
end
puts ' ' * (size[1] / 2 - ((str.length - size[1] / (deep * 2)) / 2) - 2) + 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.

deep = gets.chomp.to_i
puts 'Enter basic value'
basic_val = gets.chomp.to_i
pasc_tri = [[basic_val]]
Copy link
Contributor

Choose a reason for hiding this comment

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

pascal_triangle?

pasc_tri.push(ar)
end

require 'io/console'
Copy link
Contributor

Choose a reason for hiding this comment

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

require в начало файла

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