Generating Function for Pinsky's Combinatorial Second Moment Formula for the Generalized Ulam Problem