Exact Finite Method of Lattice Statistics. I. Square and Triangular Lattice Gases of Hard Molecules