Riddle-game was an ancient game of the Hobbits, used as a means of settling disputes. The players continued to ask each other riddles until one failed to provide a correct answer.
The most famous version is the one in which Bilbo Baggins and Gollum competed in. If Gollum failed to answer a riddle, he would show Bilbo out of the Misty Mountains. However, if Bilbo lost, Gollum would eat him. The two echanged several riddles, and Gollum's knowledge of the answers suggested to Gandalf years later that he had possibly been a hobbit once. At last, strapped for riddles to ask the loathsome creature, Bilbo, touching the ring he had found in the tunnels, asked "What have I got in my pocket?" It wasn't exactly a riddle, but Gollum failed to answer correctly, despite having 3 guesses. Despite his promise, Gollum plotted to use his "Precious" to murder and eat Bilbo, but when he found it missing, he too late guessed the right answer to Bilbo's "riddle".
Most adaptations, such as the Rankin/Bass film and BBC's radio program, have Bilbo and Gollum exchanging only two riddles each, though they both contain Bilbo's egg riddle, Gollum's time riddle, and "What have I got in my pocket?".