Toi Toi wrote:
> def calc nums, level
>   tmp = []
>   nums.each{ |n| tmp.push n
>     nums.each{ |n2| tmp.push n+n2
>       nums.each{ |n3| tmp.push n+n2+n3
>       }}}
>   tmp
> end
> 
> puts calc(["0", "1"], 3)

Look at Array#enumeration in my ISC-licensed combinatorics library:
http://github.com/sunaku/inochi/blob/master/lib/inochi/util/combo.rb

With that library, your question can be answered as follows:

sun@yantram ~/s/inochi> irb -r pp -r lib/inochi/util/combo.rb
## ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
>> pp ["0", "1"].enumeration(3)
[["0", "0", "0"],
 ["0", "0", "1"],
 ["0", "1", "0"],
 ["0", "1", "1"],
 ["1", "0", "0"],
 ["1", "0", "1"],
 ["1", "1", "0"],
 ["1", "1", "1"]]
=> nil
-- 
Posted via http://www.ruby-forum.com/.