From c5ba52de0402faff4e35f3ea8f0d843434c1dd8a Mon Sep 17 00:00:00 2001 From: YuruKravchenko Date: Mon, 19 Feb 2018 21:31:57 -0800 Subject: [PATCH 1/8] implement hw 1 --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 17 ++++++++++++++ .../homework-1/pascal_tree_2.rb | 23 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 2018/YuryKravchenko/homework-1/pascal_tree.rb create mode 100644 2018/YuryKravchenko/homework-1/pascal_tree_2.rb diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb new file mode 100644 index 000000000..62cceb754 --- /dev/null +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -0,0 +1,17 @@ +# My Homework + +def pascal(n) + + (0..n).each{|r| + tree=[1] + term=1 + k=1 + (0..r-1).step(1){|index| + term=term*(r-k+1)/k + tree.push term + k+=1} + p tree} +end +print "Введите глубину дерева: " +n = gets.to_i +pascal(n) diff --git a/2018/YuryKravchenko/homework-1/pascal_tree_2.rb b/2018/YuryKravchenko/homework-1/pascal_tree_2.rb new file mode 100644 index 000000000..511726e48 --- /dev/null +++ b/2018/YuryKravchenko/homework-1/pascal_tree_2.rb @@ -0,0 +1,23 @@ +# My Homework + +def pascal(n) + +print "Введите базовый номер: " +f = gets.chomp.to_i +h = f + + (0..n).each{|r| + tree=[h] + base=f + k=1 + (0..r-1).step(1){|index| + base=base*(r-k+1)/k + tree.push base + k+=1} + p tree} +end +print "Введите глубину дерева: " +n = gets.chomp.to_i + +pascal(n) + From 0d73452b49869d5dd8422378f59bc5526869f57e Mon Sep 17 00:00:00 2001 From: YuruKravchenko Date: Mon, 19 Feb 2018 22:50:00 -0800 Subject: [PATCH 2/8] implement hw 1 --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 26 ++++++++++--------- .../homework-1/pascal_tree_2.rb | 23 ---------------- 2 files changed, 14 insertions(+), 35 deletions(-) delete mode 100644 2018/YuryKravchenko/homework-1/pascal_tree_2.rb diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb index 62cceb754..53b16bc25 100644 --- a/2018/YuryKravchenko/homework-1/pascal_tree.rb +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -1,17 +1,19 @@ # My Homework - def pascal(n) - +print 'Введите базовый номер: ' +f = gets.chomp.to_i +h = f (0..n).each{|r| - tree=[1] - term=1 - k=1 - (0..r-1).step(1){|index| - term=term*(r-k+1)/k - tree.push term - k+=1} - p tree} + tree = [h] + base = f + k = 1 + (0..r - 1).step(1){|index| + base = base * ( r - k + 1 ) / k + tree.push base + k += 1} + p tree} end -print "Введите глубину дерева: " -n = gets.to_i +print 'Введите глубину дерева: ' +n = gets.chomp.to_i pascal(n) + diff --git a/2018/YuryKravchenko/homework-1/pascal_tree_2.rb b/2018/YuryKravchenko/homework-1/pascal_tree_2.rb deleted file mode 100644 index 511726e48..000000000 --- a/2018/YuryKravchenko/homework-1/pascal_tree_2.rb +++ /dev/null @@ -1,23 +0,0 @@ -# My Homework - -def pascal(n) - -print "Введите базовый номер: " -f = gets.chomp.to_i -h = f - - (0..n).each{|r| - tree=[h] - base=f - k=1 - (0..r-1).step(1){|index| - base=base*(r-k+1)/k - tree.push base - k+=1} - p tree} -end -print "Введите глубину дерева: " -n = gets.chomp.to_i - -pascal(n) - From 33f8016106168df8f8d8925e836049e2d7efc1da Mon Sep 17 00:00:00 2001 From: YuryKravchenko <36518159+atom-unique@users.noreply.github.com> Date: Tue, 20 Feb 2018 11:06:57 +0300 Subject: [PATCH 3/8] Update pascal_tree.rb --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb index 53b16bc25..705cfe9fe 100644 --- a/2018/YuryKravchenko/homework-1/pascal_tree.rb +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -1,19 +1,18 @@ # My Homework -def pascal(n) -print 'Введите базовый номер: ' -f = gets.chomp.to_i -h = f - (0..n).each{|r| + def pascal(n) + print 'Введите базовый номер: ' + f = gets.chomp.to_i + h = f + (0..n).each { |r| tree = [h] base = f k = 1 - (0..r - 1).step(1){|index| + (0..r - 1).step(1) { |index| base = base * ( r - k + 1 ) / k - tree.push base + tree.push base k += 1} p tree} -end -print 'Введите глубину дерева: ' -n = gets.chomp.to_i -pascal(n) - + end + print 'Введите глубину дерева: ' + n = gets.chomp.to_i + pascal(n) From 4abf96566f461b4cfce2637e8c378aa746cf54de Mon Sep 17 00:00:00 2001 From: YuryKravchenko <36518159+atom-unique@users.noreply.github.com> Date: Tue, 20 Feb 2018 11:09:05 +0300 Subject: [PATCH 4/8] Update pascal_tree.rb --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb index 705cfe9fe..3821c5452 100644 --- a/2018/YuryKravchenko/homework-1/pascal_tree.rb +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -1,18 +1,18 @@ # My Homework - def pascal(n) +def pascal(n) print 'Введите базовый номер: ' f = gets.chomp.to_i h = f - (0..n).each { |r| - tree = [h] - base = f + (0..n).each { |r| + tree = [h] + base = f k = 1 - (0..r - 1).step(1) { |index| - base = base * ( r - k + 1 ) / k + (0..r - 1).step(1) { |index| + base = base * ( r - k + 1 ) / k tree.push base k += 1} p tree} - end - print 'Введите глубину дерева: ' - n = gets.chomp.to_i - pascal(n) +end +print 'Введите глубину дерева: ' +n = gets.chomp.to_i +pascal(n) From 9ec658490ef3f86d6ac42c9374ec043d90ed8da9 Mon Sep 17 00:00:00 2001 From: YuryKravchenko <36518159+atom-unique@users.noreply.github.com> Date: Tue, 20 Feb 2018 11:56:01 +0300 Subject: [PATCH 5/8] Update pascal_tree.rb --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb index 3821c5452..2044cce3f 100644 --- a/2018/YuryKravchenko/homework-1/pascal_tree.rb +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -1,18 +1,18 @@ -# My Homework -def pascal(n) - print 'Введите базовый номер: ' - f = gets.chomp.to_i - h = f - (0..n).each { |r| - tree = [h] - base = f - k = 1 - (0..r - 1).step(1) { |index| - base = base * ( r - k + 1 ) / k - tree.push base - k += 1} - p tree} -end -print 'Введите глубину дерева: ' -n = gets.chomp.to_i -pascal(n) + # My Homework + def pascal(n) + print 'Введите базовый номер: ' + f = gets.chomp.to_i + h = f + (0..n).each { |r| + tree = [h] + base = f + k = 1 + (0..r - 1).step(1) { |index| + base = base * ( r - k + 1 ) / k + tree.push base + k += 1} + p tree} + end + print 'Введите глубину дерева: ' + n = gets.chomp.to_i + pascal(n) From 4bf4ba4607b1c07a6999e321d5560b419e66ace1 Mon Sep 17 00:00:00 2001 From: YuryKravchenko <36518159+atom-unique@users.noreply.github.com> Date: Tue, 20 Feb 2018 12:06:04 +0300 Subject: [PATCH 6/8] Update pascal_tree.rb --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb index 2044cce3f..6a7675866 100644 --- a/2018/YuryKravchenko/homework-1/pascal_tree.rb +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -1,4 +1,3 @@ - # My Homework def pascal(n) print 'Введите базовый номер: ' f = gets.chomp.to_i From e3e32ecbc7e046223f3c905977f817d376f1b29d Mon Sep 17 00:00:00 2001 From: YuryKravchenko <36518159+atom-unique@users.noreply.github.com> Date: Tue, 20 Feb 2018 12:14:33 +0300 Subject: [PATCH 7/8] Update pascal_tree.rb --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb index 6a7675866..9fdb17407 100644 --- a/2018/YuryKravchenko/homework-1/pascal_tree.rb +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -1,17 +1,17 @@ - def pascal(n) - print 'Введите базовый номер: ' - f = gets.chomp.to_i - h = f - (0..n).each { |r| - tree = [h] - base = f - k = 1 - (0..r - 1).step(1) { |index| - base = base * ( r - k + 1 ) / k - tree.push base - k += 1} +def pascal(n) + print 'Введите базовый номер: ' + f = gets.chomp.to_i + h = f + (0..n).each { |r| + tree = [h] + base = f + k = 1 + (0..r - 1).step(1) { |index| + base = base * ( r - k + 1 ) / k + tree.push base + k += 1} p tree} - end - print 'Введите глубину дерева: ' - n = gets.chomp.to_i - pascal(n) +end +print 'Введите глубину дерева: ' +n = gets.chomp.to_i +pascal(n) From e8a763ec88ab405580e83f08011ccb0dfcb96903 Mon Sep 17 00:00:00 2001 From: YuryKravchenko <36518159+atom-unique@users.noreply.github.com> Date: Wed, 21 Feb 2018 09:21:35 +0300 Subject: [PATCH 8/8] Update pascal_tree.rb --- 2018/YuryKravchenko/homework-1/pascal_tree.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2018/YuryKravchenko/homework-1/pascal_tree.rb b/2018/YuryKravchenko/homework-1/pascal_tree.rb index 9fdb17407..1e2345f4a 100644 --- a/2018/YuryKravchenko/homework-1/pascal_tree.rb +++ b/2018/YuryKravchenko/homework-1/pascal_tree.rb @@ -9,7 +9,7 @@ def pascal(n) (0..r - 1).step(1) { |index| base = base * ( r - k + 1 ) / k tree.push base - k += 1} + k += 1} p tree} end print 'Введите глубину дерева: '