The Gambler's Problem and Beyond