diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
commit | 26c490f404731d053a6205719b6246502c07b449 (patch) | |
tree | 3aa721098f1251dfbf2249ecd2736434c13b1d48 /algorithms/cyk_loops.rb |
init
Diffstat (limited to 'algorithms/cyk_loops.rb')
-rwxr-xr-x | algorithms/cyk_loops.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/algorithms/cyk_loops.rb b/algorithms/cyk_loops.rb new file mode 100755 index 0000000..e8450cd --- /dev/null +++ b/algorithms/cyk_loops.rb @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby + + +n=5 +(2..n).each { |gap| + (0..(n-gap)).each { |i| + k = i+gap + ((i+1)..(k-1)).each { |j| + puts "#{i},#{k}" + puts " #{i},#{j}" + puts " #{j},#{k}" + } + #puts + } +} + +(2..n).each { |i| + (0..(n-i)).each { |j| + puts "#{j} #{j+i}" + (1..n).each { |l| + (j..(j+i-l)).each { |k| + puts " #{k} #{k+l}" + } + } + + } +} + |