hey everyone,this might be a hard subject, but ill ask anyways. I created this guessing game, 1 random number is randomly created and i get 5 chances to guess it correctly, if i do so in 5, i get 1 "bull" (point) if i dont, the computer does, and it keeps track of points. This is fairly easy and i did it no problem. HOWEVER, part B) of the program is killing me!!! i have to now randomly generate 3 random letters (A-E) [and they cannot be the same] and guess 1 letter at a time till i get all 3. i.e. ABE is randomly created, if i guess C and hit "guess" button, i get 1 "miss" if i guess A i get a "bull" and score a point. Althought i thought this would be easy, i am having SOOOOOOO much trouble, can anyone PLEASE help me out? what would be the easiest way of approaching it? im really stuck on the validation part, i.e. after i submit the letter, how do i validate it against the "secret" random 3 letter'd word already created to see if theres a letter in it ? please help i am in dire trouble. [removed the "HELP" from the subject, as it's somewhat redundant when asking questions in a forum - Ilja] [ April 30, 2004: Message edited by: Ilja Preuss ]
Mark, I'm not sure what this has to do with performance, but remember letters are ordered in ASCII. So you can use the same idea as with the numbers and add the letter to 'A'. For example, 'A' + 2 = 'C'
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I think I heard you have to use A through E with no duplicates. So BDE would be good, but ABB would not. A common approach is to "shuffle" the list. It works well for shuffling cards or generating lottery numbers. To get three random letters, try something like this:
Try this and see what kind of scrambles you get. You might shuffle more than once if you don't trust one round of swapping.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi