bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-apl] How to zero every other 1 in a sequence


From: Elias Mårtenson
Subject: [Bug-apl] How to zero every other 1 in a sequence
Date: Wed, 19 Mar 2014 22:29:05 +0800

I've been struggling with this one for days now, and I really need some advice.

Assume I have a binary sequence. Say, something like this:

0 0 1 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1

Here, we can see a few sequences of consecutive ones. I want to zero out every second in each sequence. I.e, I'd like to get the following result:

0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1

If there is a way to do this by starting with zero instead, that would work too:

0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0

What is the shortest way of achieving this?

Regards,
Elias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]