小编Ste*_*eve的帖子

为什么这两个功能之间的速度差异如此之大?

我一直在阅读麻省理工学院的一些开放式课件,他们有一个问题是这样的:

6)考虑下面指定的用于播放"猜数字游戏"的两个函数.

def cmpGuess(guess):
"""Assumes that guess is an integer in range(maxVal). returns -1 if guess is < than the magic number, 0 if it is equal to the magic number and 1 if it is greater than the magic number."""
def findNumber(maxVal):
"""Assumes that maxVal is a positive integer. Returns a number, num, such that cmpGuess(num) == 0."""
Write a Python implementation of findNumber that guesses the magic number defined by cmpGuess. Your program should have the lowest time …
Run Code Online (Sandbox Code Playgroud)

python performance function

5
推荐指数
2
解决办法
418
查看次数

标签 统计

function ×1

performance ×1

python ×1