Change (combined-dimensions ...) to solve the general case.

Take the existing approach, written on a case by case basis for [1D 2D 3D] x [1D 2D 3D], and write the general algorithm for arbitrary sets of dimensions.