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

• To: mathgroup at smc.vnet.net
• Subject: [mg52172] Challenge: Fastest method to convert positive integers to 1 in a long list
• From: "Carl K. Woll" <carlw at u.washington.edu>
• Date: Sat, 13 Nov 2004 04:40:26 -0500 (EST)
• Organization: University of Washington
• Sender: owner-wri-mathgroup at wolfram.com

```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

```

• Prev by Date: Accumulating error counts?
• Next by Date: Matrix Dot Product
• Previous by thread: Re: Accumulating error counts?
• Next by thread: Re: Challenge: Fastest method to convert positive integers to 1 in a long list