给定数组a[1,2,3],用a里面的元素来生成一个长度为5的数组,打印出其排列组合 ruby代码: def all_possible_arr arr, length = 5 ret = [] length.times do if ret.empty? ret = arr.map {|i| [i]} else new_ret = [] ret.each do |r| arr.each do |e| new_ret << r.clone.unshift(e) end end ret = new_r…