Back
Close
  • 11

What will I learn?

Combinatorics

Statement

 Goal

This is an adaptation of a classic game of Bulls and Cows, where you will have to guess the number on the base of hints given each turn. One can also start by solving a slightly more simple version of the game.

  Rules

1. At the start of the game player will get the numberLength of the secret number.

2. Each turn player is trying to guess the secret number.

3. After each guess player will know how many bulls and cows were in the last guess, where
bull is a digit in your guess that exactly matches the value and position of a digit in secret number.
cow indicates a digit in your guess that matches the value of a digit in your opponent's secret number, but is in the wrong position.

4. Each digit of the secret number is unique as well as should be the digits of the guess.

5. First digit of a guess and of the secret number can not be a 0.

6. Score board is ascended by the total count of actions among all the test cases.



Initialization input
First line: numberLength, count of digits in the secret number.

Input for a game round
2 integers bulls and cows - count of bulls and cows in a guess, -1 -1 at the first turn
Output
Single line of numberLength digits
Constraints
0 < numberLength < 11
maxTurns = 300
turnMaxTime = 50ms
Solve it

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants