Experienced Challenge 8: Twenty Questions
Office Programs Required |
Microsoft Access 2007 |
Goldfish Awarded |
20 |
Deadline for Submission |
Wednesday, April 29, 2009 (8:00 AM Pacific Daylight Time) |
Files Required |
Experienced_challenge_8.accdb in the OfficePalooza Challenge Pack. |
Have you ever played the game Twenty Questions? If not, that’s OK: it’s about as simple a game as there is. The game is typically played by two people. Person A thinks of something; let’s say Person A thinks of a movie star. Person B’s job is to guess the movie star Person A is thinking of. And how is Person B supposed to do that? Here’s how: by asking as many 20 yes/no questions. For example, a game of Twenty Questions might start out like this:
“Is this movie star a man?”
“No.”
“Is this movie star more than 40 years old?”
“Yes.”
“Has this movie star ever been the star of a prime time television show?”
“Yes.”
And so on, and so on. And so on.
As you might have guessed (See? You are good at guessing games like this, aren’t you?), Challenge 8 in this year’s OfficePalooza festivities revolves around the game of Twenty Questions. (Which, come to think of it, probably is the reason we titled this challenge Twenty Questions.) To complete this challenge you need to grab a copy of the file Experienced_challenge_8.accdb from the OfficePalooza Challenge Pack . That file contains a database table named AnimalFacts as well as a database form that looks a lot like this:
Your task is to write a Visual Basic for Applications subroutine that can play a game of Twenty Questions. You’ll think of an animal (one of the animals found in the AnimalFacts table), and your VBA subroutine will try to guess the animal you’re thinking of. How’s it supposed to do something like that? Sorry, but even if we knew, we couldn’t tell you. That would take all the fun out of this challenge, wouldn’t it?
To complete the challenge, open the New Game form, right-click the New Game button, and then click Build Event. That will open up the Visual Basic Editor, along with the following subroutine:
Private Sub Command8_Click()
End Sub
All you have to do is enter the code for playing Twenty Questions as part of this subroutine. (Note that all the code must be included in this subroutine; this is due to the way we have to test this code.) Your subroutine should try to guess the animal you are thinking of, relying on the information in the AnimalFacts table as well as your answers to a series of yes or no questions. If the subroutine guesses the animal in 20 or fewer questions than the computer wins. Otherwise, you win.
Although everyone who participates in OfficePalooza is a winner.
Except , of course, for those who lose.
Note that your subroutine does not have to win in order to get credit for this challenge. It just needs to play the game.
Submitting Your Entry
The OfficePalooza sweepstakes is over, but you’re welcome to try the challenges and learn on your own. Good luck!