MSTRMND - Mastermind

no tags 

Task (the rules of the game) requires to guess the code which consists of four elements. Each element of the code can have one of six different values. The same values can appear multiple times. The code should be guessed in a maximum amount of ten tries. After guessing the code (or after using up the limit of ten tries) your program should end.

Input/output

During each try you give your suggestion of a correct code – you output four numbers from a range of one to six on the standard output. In the response you get a hint about which elements were typed correctly and which were not – you read four numbers and each of them can have one of those values: 1 (the number is correct), 0 (element is not in the right place) or -1 (the element is incorrect).

Example

You:    1  1  1  2
Judge:  1  1 -1  1

You:	3  4  5  6
Judge: -1 -1 -1  0

You:	1  1  6  2
Judge:	1  1  1  1

Remark: Program should clear the output buffer after printing each line. It can be done using fflush(stdout) command or you can set the proper type of buffering at the beginning of the execution - setlinebuf(stdout).


hide comments
tanzin26337: 2021-02-08 17:36:45

To avoid WA, print space between outputs

Last edit: 2021-02-08 17:41:04
Simes: 2020-11-18 22:44:58

@nadstratosfer - I agree. Like you, I got AC with simple code that didn't even use all the available information. When I tried a more rigorous approach, I get WA. Adding an assert showed there were no valid guesses remaining.

nadstratosfer: 2019-07-18 22:36:35

There's something wrong with this problem. I got AC with a somewhat dumb code, but a smarter algo using 3-5 queries to guess the answer keeps getting WA. The algo prunes the space of all possible configurations based on judge responses, and according to my experiments here, sometimes runs out of valid guesses already after second query. I wrote a tester that runs my solution against all 1296 configurations and, except for cases used for first 2 queries, this never happens. The only way I could explain this is that the judge lies sometimes.

Had a blast revisiting this game after 30+ years anyway.

kasa_praneeth9: 2017-05-09 20:38:40

can someone please check my code source id:
19373877

Last edit: 2017-05-09 20:39:00
dante: 2015-01-11 09:18:18

I am getting Internal Error, why?


Added by:japi
Date:2010-09-19
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64