(* ct.m: A shorter program to get hypergeometric generating functions
         for the kk X nn transportation problem.     May 8, 1996.  *)
(* Usage. 1. Set kk, nn and a. 2. Load the program (e.g. <<ct.m) 3. hg[g] *)
Clear[kk,nn,u,x,a];
kk=3; nn=6;
a = {11,3,4,5,6,7}; (* Example of a. 15.3s. *)
hg[a_]:=Module[{r,i,j},
 If[TrueQ[Sum[a[[i]],{i,1,kk}] != Sum[a[[i]],{i,kk+1,nn}]],Return["ERROR"]];
 r=Expand[Product[(Sum[u[i,j]*x[j],{j,kk+1,nn}]/. {x[1]->1})^(a[[i]]),{i,1,kk}]];
 For[i=kk+1,i<=nn,i++, r=Coefficient[r,x[i],a[[i]]]]; Return[r];
]
