Re: Challenge: Fastest method to convert positive integers to 1 in a long list

*To*: mathgroup at smc.vnet.net*Subject*: [mg52237] Re: [mg52172] Challenge: Fastest method to convert positive integers to 1 in a long list*From*: János <janos.lobb at yale.edu>*Date*: Mon, 15 Nov 2004 20:56:52 -0500 (EST)*References*: <200411130940.EAA01037@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Try this: In[131]:= max = Max[seq]; Timing[Quotient[seq + max - 1, max]; ] Out[132]= {0.0800000000000125*Second, Null} János On Nov 13, 2004, at 4:40 AM, Carl K. Woll wrote: > Hi all, > > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers > in a > long sequence of nonnegative integers to 1, so that the sequence > consists of > only 0s and 1s. Let the sequence be given by > > seq = Table[Random[Integer, 10], {10^6}]; > > Then, one technique is > > newseq = 1+Quotient[#,#+1,1]&@seq; > > Can anyone do better? > > Carl Woll > > ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice)

**References**:**Challenge: Fastest method to convert positive integers to 1 in a long list***From:*"Carl K. Woll" <carlw@u.washington.edu>