This article mainly introduces the Python implementation of guessing game algorithm, a simple description of the guessing game principle, and combined with specific examples to analyze the Python crack guessing game related implementation skills, the need for friends can refer to the next
In this paper, the implementation of the Python algorithm to solve the guessing game is described. Share to everyone for your reference, as follows:
QQ Group in the chat robot will start guessing games. Play as follows:
1. The user sends #猜数 into the group
2. Robot response: The number of guesses has started, the range is a number between 1-10000
3. You send #猜数 [123] into the group
4. Robot response: Big or small, or congratulations on your guess.
5. You according to just guess 123, and return, guess a smaller or larger number, send #猜数 [111], that is, to return to the 2nd step
Then the best way to guess is definitely to find the center number, because the mental arithmetic time-consuming, so directly on the Python script to crack this:
#!/usr/bin/env python#-*-coding:utf-8-*-__author__ = ' Huhu,