wu :: forums
« wu :: forums - does secret key exist? »

Welcome, Guest. Please Login or Register.
Apr 28th, 2024, 1:14pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Eigenray, Icarus, william wu, ThudnBlunder, SMQ, Grimbal, towr)
   does secret key exist?
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: does secret key exist?  (Read 4720 times)
inexorable
Full Member
***





   


Posts: 211
does secret key exist?  
« on: Oct 22nd, 2012, 3:08pm »
Quote Quote Modify Modify

Mastermind is a game of two players. In the beginning, first player decides a secret key, which is a sequence (s1,s2,...sk) where 0 < si <= n, Then second player makes guesses in rounds, where each guess is of form (g1,g2, ...gk), and after each guess first player calculates the score for the guess. Score for a guess is equal to number of i's for which we have gi = si.
 
For example if the secret key is (4,2,5,3,1) and the guess is (1,2,3,7,1),then the score is 2, because
g2 = s2 and g5 = s5.  
 
Given a sequence of guesses, and scores for each guess, your program must decide if there exists at least one secret key that generates those exact scores.
IP Logged
Johnson
Newbie
*



G33k

   


Gender: male
Posts: 5
Re: does secret key exist?  
« Reply #1 on: Dec 2nd, 2012, 8:50am »
Quote Quote Modify Modify

seem like a cool game.
 
 
 
 
 
 
 
 
 
________________________________________________________
Riddle : A Cat in the Hat With
(spam removed) in one hand.
« Last Edit: Dec 6th, 2012, 4:51am by Grimbal » IP Logged
wiley
Newbie
*





   


Posts: 12
Re: does secret key exist?  
« Reply #2 on: Dec 5th, 2012, 9:35am »
Quote Quote Modify Modify

Just puting my thoughts:
 
- Take a guess with maximum count. say: x1,x2,..xk
- Invalidate locations if possible, for example: say there exists another guess with count 0 and its 2nd location equals x2. So x2 cannot be right.
 
After good number of in-validations, we'll reach a state where we can positively say the particular location's value. for example: say there exists another guess with count 1 and all keys invalid except at location 3. And location 3 matches x3.
 
If we keep doing this iteratively again and again, we should reach the state where we can positively find a secret key or fails due to un-knowns.
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board