-
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
Homework 1 #762
base: master
Are you sure you want to change the base?
Homework 1 #762
Conversation
basic_val = gets.chomp.to_i | ||
pasc_tri = [[basic_val]] | ||
|
||
(1..(deep - 1)).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.
либо (deep - 1).times do
либо (1...deep).each do
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.
Используй более читаемые переменные вместо i, j, m и прочего. Ниже тоже.
|
||
(1..(deep - 1)).each do |i| | ||
ar = [] | ||
(0..i).each do |j| |
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.
times
require 'io/console' | ||
size = IO.console.winsize | ||
|
||
(0..(deep - 1)).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.
аналогично выше.
(0..(deep - 1)).each do |i| | ||
str = '' | ||
print "#{i}:" | ||
(0..i).each do |j| |
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.
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 |
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.
deep = gets.chomp.to_i | ||
puts 'Enter basic value' | ||
basic_val = gets.chomp.to_i | ||
pasc_tri = [[basic_val]] |
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.
pascal_triangle
?
pasc_tri.push(ar) | ||
end | ||
|
||
require 'io/console' |
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.
require в начало файла
Фамилия Имя
Шкрабков Владислав
Email
[email protected]
Номер домашнего задания
1
Ссылка на видео с демо работы
https://youtu.be/AJvJDC_d7ag
Комментарии
Делал сразу 3 lvl. Алгоритм создания и вывода похож на всех трех уровнях, только добавляются какие-то доп условия на каждом уровне.