calculate number of transitions between number of intervals of 'road functions'

At the definition of a street renovation project, a street or street section (e.g. length = 100m) is split into strips, e.g. 1.pavement 2.road 3.parking 4.pavement.

However, some strips have more than 1 'function', e.g. strip 3 consists of parkingspots, alternated with some vegetation spots and (garage) exits: it is a 'mixed' strip.

__http://infra.ft2.nl/picture_0.jpg__

The roadplanner fills out the road profile with strips and functions. For the 'mixed' strip, he fills out the following information (example):

- parking, 50 meter, 4 intervals

- vegetation, 20 meter, 6 intervals

- exit, 30 meter, 3 intervals

The length of each function is the total length of all intervals of that function.

The visualisation only shows the 3 functions and not the number of intervals. The planner can not draw/enter each individual interval (as this could take too much time)

__QUESTION:__ IS THERE AN 'ALGORITHM' WHICH CALCULTES THE NUMBER OF TRANSITIONS BETWEEN (each possible combination of) 2 FUNCTIONS?

- there is no difference between a transition from functionA-to-functionB and functionB-to-functionA

- it can be assumed that the maximum number of functions is 5

- it doesn't realy matter with which function the section starts and with which one it ends

- the calculation of the number of transitions does not have to be exact (a deviation of 2 per tranistion between 2 function can be accepted, but the more accurate the better...).

- Please specify assumptions you make to get a working algorithm

**Example 1**

actual situation: http://infra.ft2.nl/picture_1.jpg

*Input* in tool:

- parking, x meter, 4 intervals

- vegetation, y meter, 4 intervals

- exit, z meter, 3 intervals

*This should lead to following output of the algorithm I am looking for (or results close to this)*:

From parking to vegetation (or vice versa): 4 transistions

From parking to exit (or vice versa): 3 transistions

From exit to vegetation (or vice versa): 3 transistions

Example ** 2** (

actual situation: http://infra.ft2.nl/picture_2.jpg

*Input* in tool:

- parking, x meter, 5 intervals

- vegetation, y meter, 3 intervals

- exit, z meter, 2 intervals

*This should lead to following output of the algorithm I am looking for (or results close to this)*

From parking to vegetation (or vice versa): 4 transistions

From parking to exit (or vice versa): 3 transistions

From exit to vegetation (or vice versa): 1 transistions