A heat engine is a machine which uses the temperature difference between a hot and a cold reservoir to extract work. Here both reservoirs are quantum systems and a heat engine is described by a unitary transformation which decreases the average energy of the bipartite system. On the molecular scale, the ability of implementing such a unitary heat engine is closely connected to the ability of performing logical operations and classical computing. This is shown by several examples: (1) The most elementary heat engine is a SWAP-gate acting on 1 hot and 1 cold two-level systems with different energy gaps. (2) An optimal unitary heat engine on a pair of 3-level systems can directly implement OR and NOT gates, as well as copy operations. The ability to implement this heat engine on each pair of 3-level systems taken from the hot and the cold ensemble therefore allows universal classical computation. (3) Optimal heat engines operating on one hot and one cold oscillator mode with different frequencies are able to calculate polynomials and roots approximately. (4) An optimal heat engine acting on 1 hot and n cold 2-level systems with different level spacings can even solve the NP-complete problem KNAPSACK. Whereas it is already known that the determination of ground states of interacting many-particle systems is NP-hard, the optimal heat engine is a thermodynamic problem which is NP-hard even for n non-interacting spin systems. This result suggest that there may be complexity-theoretic limitations on the efficiency of molecular heat engines.