Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: aix aix Newsgroups: comp.lang.ruby Subject: Calcul XOR : array , times. Date: Fri, 13 May 2011 07:25:53 -0500 Organization: Service de news de lacave.net Lines: 91 Message-ID: NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: Quoted-printable X-Trace: talisker.lacave.net 1305289578 18532 65.111.164.187 (13 May 2011 12:26:18 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 13 May 2011 12:26:18 +0000 (UTC) X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 383201 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:4483 Hello , I have problems with my code for XOR calcul : a =3D [1, 0, 1, 1, 0, 0, 1] b =3D ["101101", "101100", "110011", "000111", "010110"] # good result : 000001, 011010,101000, 001010,110000 # false result : ["000001", "000000", "011111", "101011", "111010"] =3D> output with this code # Why ? Because he spends that time with respect b[i].lenght ( =3D 6 generally ) that prevents take in this case the element 7 and 8 of "a". # works in case a.length 7` and `b[x].length =3D>6` In this code, the xor calcul is performed with only 6 elements in a on 7. So the calculation is performed here: a[0] ^ b[0][0] ; a[1] ^ b[0][1] ; a[2] ^ b[0][2] ; a[3] ^ b[0][3] ; a[4] ^ b[0][4] ; a[5] ^ b[0][5] ; a[0] ^ b[1][0] ; a[1] ^ b[1][1] ; a[2] ^ b[1][2] ; a[3] ^ b[1][3] ; a[4] ^ b[1][4] ; a[5] ^ b[1][5] ; a[0] ^ b[2][0] ; a[1] ^ b[2][1] ; a[2] ^ b[2][2] ; a[3] ^ b[2][3] ; a[4] ^ b[2][4] ; a[5] ^ b[2][5] ; a[0] ^ b[3][0] ; a[1] ^ b[3][1] ; a[2] ^ b[3][2] ; a[3] ^ b[3][3] ; a[4] ^ b[3][4] ; a[5] ^ b[3][5] ; a[0] ^ b[4][0] ; a[1] ^ b[4][1] ; a[2] ^ b[4][2] ; a[3] ^ b[4][3] ; a[4] ^ b[4][4] ; a[5] ^ b[4][5] ; `a[6]` is never use. and the calculation should be done: a[0] ^ b[0][0] ; a[1] ^ b[0][1] ; a[2] ^ b[0][2] ; a[3] ^ b[0][3] ; a[4] ^ b[0][4] ; a[5] ^ b[0][5] ; a[6] ^ b[1][0] ; a[0] ^ b[1][1] ; a[1] ^ b[1][2] ; a[2] ^ b[1][3] ; a[3] ^ b[1][4] ; a[4] ^ b[1][5] ; a[5] ^ b[2][0] ; a[6] ^ b[2][1] ; a[0] ^ b[2][2] ; a[1] ^ b[2][3] ; a[2] ^ b[2][4] ; a[3] ^ b[2][5] ; a[4] ^ b[3][0] ; a[5] ^ b[3][1] ; a[6] ^ b[3][2] ; a[0] ^ b[3][3] ; a[1] ^ b[3][4] ; a[2] ^ b[3][5] ; a[3] ^ b[4][0] ; a[4] ^ b[4][1] ; a[5] ^ b[4][2] ; a[6] ^ b[4][3] ; a[0] ^ b[4][4] ; a[1] ^ b[4][5] ; I want to make the right calculation of course but I do not see how to this. How to use a[6] as above ? Thanks -- = Posted via http://www.ruby-forum.com/.=