01-01-2006, 01:52 AM

Alice and Bob are magicians. Alice asks a volunteer to randomly draw five playing cards from a deck. She takes the cards from the volunteer and looks at them without revealing them to anyone else. Alice then begins showing them to Bob one at a time. After the fourth card, Bob correctly guesses what the fifth card is. The secret to this trick was to come up with an algorithm that when given any five cards, could order four of them so that the fifth could be guessed by this order. (See where this is going yet?)

The challenge is for you to come up with said algorithm and implement it in QB or FB. Your program should describe the algorithm to the user, give him five random cards, ask for four cards back and then return the fifth. In other words, the user will be Alice and the program will be the audience member and Bob. (You just have to make sure that Bob is a separate function or that would be cheating.) There are many possible solutions, most of which are surprisingly simple.

Rules:

1) Don't post your code here! Put it in a folder along with a compiled (.exe) version of your file and fileanchor it. You can post a link to it here. This will prevent people that want to solve this themselves from having to see the answer.

2) There will be no time limit on this challenge.

3) The winner will be the first person to come up with a working program that correctly guesses the fifth card every time. However, even if there is already a winner I encourage you to still participate. I would love to see different solutions to this.

4) If you haven't found a solution, don't peek at the others. This is really for your benefit. It's much more satisfying to find a solution yourself than to just read it.

5) If after a week no one has solved this, you can PM me for a hint. After another week, you can PM again for another hint. But like I said, it's much more rewarding to solve this on your own.

6) There won't be a prize for this because, well, I don't have anything :lol: I guess a hearty pat on the back from me will have to do. And of course all the fame and recognition you get from winning a Qbasicnews challenge!

7) Finally, this isn't my homework assignment so don't harass me with accusations. I have a solution of my own already.

If you have a question about this challenge or need something explained better just post it here. I tried to explain it as plainly as possible but I know it can still sound confusing. Hopefully someone will be able to put it in simpler terms.

Ok. Have fun!

The challenge is for you to come up with said algorithm and implement it in QB or FB. Your program should describe the algorithm to the user, give him five random cards, ask for four cards back and then return the fifth. In other words, the user will be Alice and the program will be the audience member and Bob. (You just have to make sure that Bob is a separate function or that would be cheating.) There are many possible solutions, most of which are surprisingly simple.

Rules:

1) Don't post your code here! Put it in a folder along with a compiled (.exe) version of your file and fileanchor it. You can post a link to it here. This will prevent people that want to solve this themselves from having to see the answer.

2) There will be no time limit on this challenge.

3) The winner will be the first person to come up with a working program that correctly guesses the fifth card every time. However, even if there is already a winner I encourage you to still participate. I would love to see different solutions to this.

4) If you haven't found a solution, don't peek at the others. This is really for your benefit. It's much more satisfying to find a solution yourself than to just read it.

5) If after a week no one has solved this, you can PM me for a hint. After another week, you can PM again for another hint. But like I said, it's much more rewarding to solve this on your own.

6) There won't be a prize for this because, well, I don't have anything :lol: I guess a hearty pat on the back from me will have to do. And of course all the fame and recognition you get from winning a Qbasicnews challenge!

7) Finally, this isn't my homework assignment so don't harass me with accusations. I have a solution of my own already.

If you have a question about this challenge or need something explained better just post it here. I tried to explain it as plainly as possible but I know it can still sound confusing. Hopefully someone will be able to put it in simpler terms.

Ok. Have fun!