Okey, I can't resist, too, to solve this question! smile

My suggestion:
- 2 big identical terrains: one for the ground, one for the water.
- 2 times: one before pumping, one after starting to pump

- the dike is build by rising the vertices of the ground terrain, until they are above the water terrain
- when the dike is closed/complete, the water vertices test whether the corresponding vertices of the ground is under it, and if it id, it is written in a list
- then you have to place a pump on the dike with the direction from land to ocean, this pump should have two parts, each part on one side of the dike: one part for the 'in' side (the land), one part for the 'out' side (the ocean)
- now, each vertex of the water traces to the pump; when it reaches the pump at its out side, it is written in a list of the 'ocean vertices', vice versa
in case it doesn't reach the pump, but the ground terrain is in its way, it traces to each vertex of the 'ocean vertices' until it reaches one of them, then it is written into the 'ocean list', if it doesn't reach any of that vertices, it traces to the 'land vertices' until it reaches one of them, and it can be added to the list.

Now, you have to lists of vertices which you can tread depending it belongs to the ocean or to the to be drained land side!