Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Gaming > Development Programming Algorithms > Re: cows and bu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 614 of 679
Post > Topic >>

Re: cows and bulls

by "Jimmy" <onegodoneloveoneway@[EMAIL PROTECTED] > Feb 14, 2007 at 02:15 AM

On Feb 14, 1:43 pm, "ramu" <ramu....@[EMAIL PROTECTED]
> wrote:
> Hi,
>  can anyone give me the algorithm for cows and bulls game which takes
> minimum number of p***** to guess a 4-digit number?
>
> regards

I can give you the algorithm that takes the minimum number of p*****
to guess any number in a given range.

GUESS_NUMBER(MAX, NUMBER)
MIN = 0
GUESS = (MAX - MIN) / 2 + MIN
WHILE GUESS != NUMBER
         IF GUESS > NUMBER
                  MIN = GUESS
         ELSE IF GUESS < NUMBER
                  MAX = GUESS

Where MAX is the highest number, so in your case 9999, and NUMBER is
the number you're trying to guess.

Hope this helps!
 




 4 Posts in Topic:
cows and bulls
"ramu" <ramu  2007-02-13 19:43:10 
Re: cows and bulls
"Jimmy" <one  2007-02-14 02:15:25 
Re: cows and bulls
"Jimmy" <one  2007-02-14 02:18:47 
Re: cows and bulls
"Geoffrey Summerhaye  2007-02-14 12:47:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 18 19:44:24 CDT 2008.