[Chicago] Segments in binary array

Oren Livne livne at uchicago.edu
Sun Dec 23 15:39:30 CET 2012


Dear Ken and Carl,

Thank you so much! I always get quality responses from this group!
I referred to maximal ranges. So there's a single range in both 0,0,0,0 
and 0,0,0,0,0,0.
Ken's solution, with boundary cases treatment, will work for me.

Happy Holidays,
Oren

On 12/21/2012 8:03 PM, Carl Karsten wrote:
> for L = 3, how many ranges are in:
> 0,0,0,0 ?
>
> I can find 3:
> 1,2,3
> 1,2,3,4
>    2,3,4
>
> But if you are not allowed to reuse, then just the 1234 one is all there is.
>
> but that still leaves 0,0,0,0,0,0
> 123 and 456 give you 2 ranges with no reuse.  Is that better than one long one?
>
> On Fri, Dec 21, 2012 at 4:36 PM, Oren Livne <livne at uchicago.edu> wrote:
>> Dear All,
>>
>> I have a binary numpy array A. I would like to find all ranges of
>> consecutive 0's of length >= L in A. What would be an efficient
>> implementation?
>>
>> Thanks,
>> Oren
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> http://mail.python.org/mailman/listinfo/chicago
>
>


-- 
A person is just about as big as the things that make him angry.



More information about the Chicago mailing list