LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

find the counts of consecutive 0s and 1s

Solved!
Go to solution

Well, I time Crossrulz's method as taking 0.62 seconds for a run of 10 millions True/False "strings" of random length, so I seem to be faster.  Here's my code (along with the data generator).

Count Ones and Zeros.png

Bob Schor

0 Kudos
Message 21 of 38
(2,298 Views)

Put me in with the also rans.

A variation on James's theme.

consecutive ones and zeroes.png

0 Kudos
Message 22 of 38
(2,290 Views)

Crossrulz,

 

     You are right, of course -- I was just a tad embarassed from my initial post, and didn't want to waste anyone's time (I should have tested before I posted).

 

BS

0 Kudos
Message 23 of 38
(2,278 Views)

 

 

 

 

Screenshot 2015-08-14 15.30.40.png

 

 

Screenshot 2015-08-14 15.31.03.png

 

The last count in ones array ([15] probe) belong to zeros array

Screenshot 2015-08-14 15.39.42.png

0 Kudos
Message 24 of 38
(2,229 Views)

I only tested my algorithm with your first data set (it was difficult to manually enter all the data), but I got the right result, and have every expectation that my algorithm will always work (I think, if pressed, I could even prove that it would give the correct answer).  Try it, you'll like it.  Note that to convert your numeric data into an equivalent Boolean array that my algorithm prefers, you just need to pass the data through a "Not equal to 0" comparator.

Numeric to Boolean.png

Bob Schor

0 Kudos
Message 25 of 38
(2,202 Views)

I am curious why nobody is using "search array"?

 

(This is just a rough draft. I am sure it could be optimized further.)

 

Download All
0 Kudos
Message 26 of 38
(2,197 Views)

@walidbalid wrote:


 That's because "decimate array" truncates the size so the number of elements is divisible by the decimation factor. For example, if you decimate with two outputs, the input array gets truncated to be of even size.

Message 27 of 38
(2,192 Views)

0 Kudos
Message 28 of 38
(2,118 Views)
Come on, walidwalid, we've given you quite a bit of code to work with. Try messing with it yourself to get what you need here now and come back with what you've tried if it doesn't work. We can't spend our days doing your research for you.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 29 of 38
(2,106 Views)

Define "large".  Are these flat binary files? What is the exact format?

0 Kudos
Message 30 of 38
(2,100 Views)