  The guesswork quantifies the minimum cost incurred in guessing the state of
an ensemble, when only one state can be queried at a time. In the classical
case, it is well known that the optimal strategy trivially consists of querying
the states in their non-increasing order of posterior probability. In the
quantum case, on the other hand, the most general strategy to obtain the
optimal ordering in which to perform the queries consist of a quantum
measurement. Here, we solve such an optimization problem by deriving the
quantum measurement attaining the guesswork for a broad class of ensembles and
cost functions.
