def _is_this_smaller(candidate): global guess_count global larger_count guess_count = guess_count + 1 if candidate >= the_number: larger_count = larger_count + 1 return (candidate < the_number) if __name__ == "__main__": # GCD a = (int)(input("GCD, a: ")) b = (int)(input("GCD, b: ")) print(mp.gcd(a, b)) print("++++++++++++++++++++++++++\n") # Rubik's cube m = (int)(input("Rubik's Cube, m: ")) print(mp.rubiks(m)) print("++++++++++++++++++++++++++\n") # Guessing a number n = (int)(input("Guessing Game, n: ")) the_number = (int)(input("Guessing Game, the_number: ")) print(mp.guess_unlimited(n, _is_this_it)) print("++++++++++++++++++++++++++\n") # Guessing a number, with busting print(mp.guess_limited(n, _is_this_smaller))
return (candidate == the_number) def _is_this_smaller(candidate): global guess_count global larger_count guess_count = guess_count + 1 if candidate >= the_number: larger_count = larger_count + 1 return (candidate < the_number) if __name__ == "__main__": # GCD print mp.gcd(27, 27) # Rubik's cube print mp.rubiks(4) # Guessing a number n = 1000 the_number = n / 2 print mp.guess_unlimited(n, _is_this_it) # Guessing a number, with busting print mp.guess_limited(n, _is_this_smaller) print "Number of guesses: " + str( guess_count), ", Number of time busted: " + str(larger_count) # Guessing number competition