Skip to content

Commit

Permalink
commit2
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliyaBond committed Mar 15, 2018
1 parent 379e994 commit c22f465
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions 2018/YuliyaBondareva/1/pascal_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def tree(number, base_number)
s += 1
branch.push ' /'
end
arrToStr = trn.join(' ')
arr_to_str = trn.join(' ')
str_end = branch.join(' \\')
puts "#{index + 1}:" + ' ' + arrToStr.center(width[1].to_i)
puts "#{index + 1}:" + ' ' + arr_to_str.center(width[1].to_i)
if index != (number - 1)
puts ' ' + "#{str_end} \\".center(width[1].to_i)
end
Expand All @@ -26,11 +26,15 @@ def tree(number, base_number)
puts 'Depth?'
number = gets.chomp
base_number = ENV['BASE']
while number.to_i <= 0 || number.nil? || base_number.to_i <= 0 do
puts 'BASE and depth must be positive. '
while number.to_i <= 0 do
puts 'depth must be positive. '
puts 'Depth?'
number = gets.chomp

end
while base_number.to_i <= 0 do
puts 'BASE must be positive. '
puts 'BASE?'
base_number = gets.chomp
base_number = gets.chomp
end
tree(number.to_i, base_number.to_i)

0 comments on commit c22f465

Please sign in to comment.