We consider quantum Hamiltonians of the form H = H-0 - U Sigma(j) cos(C-j), where H-0 is a quadratic function of position and momentum variables x(1), p(1), x(2), p(2),... and the C-j s are linear in these variables. We allow H-0 and Cj to be completely general with only two restrictions: we require that (1) the C-j s are linearly independent and (2) [C-j,C-k] is an integer multiple of 2 pi i for all j,k so that the different cosine terms commute with one another. Our main result is a recipe for solving these Hamiltonians and obtaining their exact low-energy spectrum in the limit U -> infinity. This recipe involves constructing creation and annihilation operators and is similar in spirit to the procedure for diagonalizing quadratic Hamiltonians. In addition to our exact solution in the infinite U limit, we also discuss how to analyze these systems when U is large but finite. Our results are relevant to a number of different physical systems, but one of the most natural applications is to understanding the effects of electron scattering on quantum Hall edge modes. To demonstrate this application, we use our formalism to solve a toy model for a fractional quantum spin Hall edge with different types of impurities.