Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created January 28, 2018 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/4ae49fc199d27981091a4f31fad623bf to your computer and use it in GitHub Desktop.
Save jianminchen/4ae49fc199d27981091a4f31fad623bf to your computer and use it in GitHub Desktop.
Guess 4 digit number discussion
Please try to ask minimum number of questions to identify a four-digit number.
For example, guess 1111,
let 1111 -> 1 number is correct , 1 number at correct position
2111 -> 2q number is correct , 0 number at correct position
Analysis of the problem:
4 digits, 4 position
10^4 * 4 * 3 * 2 * 1
minimum questions I should ask 24 choices
0 - 9 10 -> one digit - 4 distinct
taking 10, give digits 4 digit , 10 times - 9 times
2 digits
3 digits
4 digits
identify ->
10 times -> at time
four digits - at most -> 0, 1, 2, ,
1, 2, -> add new digit <-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment