From: Lyndon Samson Date: 2005-10-19T08:37:43+09:00 Subject: Re: AND THE WINNER IS... [WAS] Re: How to get non-unique elements from an array? ------=_Part_21427_18098516.1129678659880 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 10/19/05, pauldacus@gmail.com wrote: > > Yes... my solution seems to suck in that it doesn't work & is slow. I > believe this makes me Management Material! > > But hopefully I can redeem myself with this humble solution (does seem > to work), which borrows heavily from my predecessors: > > one =3D {}; two =3D {}; a.each{|i| one[i] ? two[i]=3D1 : one[i]=3D1}; two= .keys Basically my ( fast :-) )solution using Hashs rather than a Bit fields... bn =3D bn2 =3D 0 a.each {|el| bn2 |=3D (1< method, which seems like it's got to be expensive on a big array. No > sorting or counting, just a straight up "If this is not the first time > I've seen this thing, then it's the second, otherwise... it's the > first". I'd benchmark, but a copy/paste on previous code blows up. I > blame Windows. > > > -- Into RFID? www.rfidnewsupdate.com Simple, fast, news. ------=_Part_21427_18098516.1129678659880--