diff --git a/2018/YuliyaBondareva/1/pascal_tree.rb b/2018/YuliyaBondareva/1/pascal_tree.rb index 88682c934..718afb204 100644 --- a/2018/YuliyaBondareva/1/pascal_tree.rb +++ b/2018/YuliyaBondareva/1/pascal_tree.rb @@ -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 @@ -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)