08-14-2015 02:25 PM
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).
Bob Schor
08-14-2015 02:27 PM
Put me in with the also rans.
A variation on James's theme.
08-14-2015 02:30 PM
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
08-14-2015 03:36 PM - edited 08-14-2015 03:41 PM
crossrulz code is super fast. However, sometimes the last zeros or ones are dropped.
Here are some examples:
[9] Probe is data array.
The last two zeros are not included in Zoros array (Probe 11)
The last three zeros are not included in Zoros array (Probe 11)
The last '1' is not included in ones array (Probe 10)
The last count in ones array ([15] probe) belong to zeros array
08-14-2015 04:20 PM
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.
Bob Schor
08-14-2015 04:23 PM - edited 08-14-2015 04:23 PM
I am curious why nobody is using "search array"?
(This is just a rough draft. I am sure it could be optimized further.)
08-14-2015 04:27 PM
@walidbalid wrote:
@crossrulz code is super fast. However, sometimes the last zeros or ones are dropped.
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.
08-15-2015 11:42 AM - edited 08-15-2015 11:43 AM
altenbach, your suggested code did very well. It's a little bit slower than crossrulz, but the truncates problem is solved. However, I had another problem which is processing supper large size data file. I'll try to split the array into subsets, process one by one, and append the outputs. The last set of 0's or 1's in each subset should be shifted to the next subset. Thanks again.
08-15-2015 11:50 AM
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-15-2015 11:53 AM
Define "large". Are these flat binary files? What is the exact format?