Application of generating functions to a problem in finite dam theory