You're playing mastermind, an algorithmic and logical game (if you don't know the rules, you can google them). You've posed the following guesses so far, and got the following results (x is RIGHT color, RIGHT location, o is RIGHT color, WRONG location):
OYPR -- xx
YBOW -- xo
BWYY -- o
What one guess can you make, that regardless of being correct, will give you a definitive answer as to what the code is?
what does the location mean, you give 2 answers for 4 stmbols
Name:
Anonymous2012-09-27 17:33
The location of the symbols is not indicative of correct placement. Given four 'colors' (or letters in this case) and two answers, two colors are neither correct, nor correct in the right place.
I think there are only 6 possible combinations >>1-kun could have - namely:
O B P P
O B P B
O B P O
O B R R
O B B R
O Y O O
O O P W
Is this correct?
My guess would then obviously have to be such, that the answer from mastermind would be different for every possible given combination.
(define possible
(amb-collect
(let ((actual (configuration)))
(assert-possible '(O Y P R) actual 2 0)
(assert-possible '(Y B O W) actual 1 1)
(assert-possible '(B W Y Y) actual 0 1)
actual
)))
(for ((g guesses))
(printf "guess ~a~n" g)
(for ((p possible))
(let ((g-right (right g p)) (g-color (right-color g p)))
(printf "~a ~a ~a~n" p g-right g-color))))
Output: guess (P B B P)
(O P P W) 0 2
(O B P P) 2 1
(O B P B) 1 2
(O B P O) 1 1
(O B R R) 1 0
(O B B R) 2 0
(O Y O O) 0 0
(O O P W) 0 1
guess (B P P B)
(O P P W) 2 0
(O B P P) 1 2
(O B P B) 2 1
(O B P O) 1 1
(O B R R) 0 1
(O B B R) 0 2
(O Y O O) 0 0
(O O P W) 1 0