Is there an easy way to zip 2 arrays in random places and keep my original order ?
eg
a=[0,1,2,3,4,5,6,7,8,9,10] b=["one","two","three","four"]
and a random number from 0 to 5 with rand(5)
zipped = [0,"one",1,2,3,"two",4,"three",5,6,7,8,"four",9,10]
and the random row will be 1,3,1,4 as the place where βzipβ each element b in
The best I could do is
i=0 merged=a b.each do |x| rnd = rand(5) merged.insert(i+rnd,x) i=i+rnd end