Dear Hansl experts,

I would like to write a Hansl code but unfortunately I'm out of creativity :(
I have a binary series with blocks of 0 and 1. Something like

X=(0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1).

Here are the steps I need do follow:

(1) Find the number of 1-blocks;
(2) Calculate the average number of observations inside these blocks.

In my hypothetical example, the X series, I have two blocks, and these
blocks have an average of 8 observations (five observations in the first
block and eleven observations in the second block).

Any help will be appreciated.

Um abraço, 
Henrique Andrade