Help for a number guessing game

Posted 01 July 2009 - 05:42 AM

I want to create a number guessing game which:
1. guesses a 4 digit number where smaller numbers are also applicable(using 0 to replace the digits)
2. use "O" to indicate correct, "X" to indicate wrong and "P" to indicate that the number is in the wrong place

the code that I have come up with is functional but the problem is that when I'm guessing a number with same digits(like 1222) if I only guess put something like 1111 the output is 4 P's, what I would like is to have just one "O" indicating that my first digit is correct and three "X" indicating the three 1s are not correct, i.e. if I input the same number 4 times to guess one number it will not give me three P's saying that they're in the wrong place but three "X" saying thy're wrong.

Replies To: Help for a number guessing game

Re: Help for a number guessing game

Posted 01 July 2009 - 07:24 AM

I made a similar program about 9 months ago. Here is the code I used for checking the right numbers or right numbers at wrong place. Hope this gives you a hint how you should do it. I made it with Java so this is a quick translation which is not tested. And of course there are some bad coding (didn't use consts etc) but anyway.