From: Harry Kakueki Date: 2011-05-14T00:17:30+09:00 Subject: Re: Calcul XOR : array , times. On Fri, May 13, 2011 at 9:25 PM, aix aix wrote: > Hello , > > I have problems with my code for XOR calcul : > >    a = [1, 0, 1, 1, 0, 0, 1] >    b = ["101101", "101100", "110011", "000111", "010110"] >    # good result : 000001, 011010,101000, 001010,110000 >    # false result : ["000001", "000000", "011111", "101011", "111010"] > > How to use a[6] as above ? > Sorry, I did not look for a problem with your code. I did it another way. This is not tested so it may have some problems but maybe it will give you some ideas. a = [1, 0, 1, 1, 0, 0, 1] b = ["101101", "101100", "110011", "000111", "010110"] bmod = b.join.split(//).map{|x| x.to_i} amod = a*(bmod.size/a.size+1) res = amod[0...bmod.size].zip(bmod).map{|z| z[0]^z[1]} p [].tap{|y| b.size.times{y << res.slice!(0...b[0].size)}}.map{|g| g.join} Harry