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

Homework 1 #762

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

Homework 1 #762

wants to merge 3 commits into from

Conversation

shkrub322
Copy link

Фамилия Имя

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

Email

[email protected]

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

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