spoj#MSTRMND. Mastermind
Mastermind
English version | Wersja polska |
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</p>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).