#!/usr/local/bin/ruby require "GSL" include GSL # Test combinations STDERR.puts "Running tests for combinations..." n = 4 k = 3 0.upto(4) do |k| c = Combination.new(n, k) c.init_first printf "\nn = %d, k = %d\n", c.n, c.k #puts c.is_valid? #puts "first combination: " + c.to_a.join(" ") #0.upto(k-1) do |i| # puts c.get(i) #end puts "each: " c.each do |k| puts k.to_a.join(" ") end puts "reverse_each: " c.reverse_each do |k| puts k.to_a.join(" ") end end # generate all "Lotto" numbers :-) #c = Combination.new(49, 6) #c.init_first #File.open("lotto.dat", "w") do |f| #c.each do |k| #k.fprintf(f, "%Zu\t") #f.puts #end #end STDERR.puts "\ndone."