def maxProduction(market, maxWeight, i, actualMilk, actualWeight, cows): if (i < len(market)): # hasta comprobar la última vaca aCow = market[index] if (actualWeight + aCow.weight <= maxWeight): #insertamos la vaca, dependiendo de la cantidad de la leche return max( maxProduction(market, maxWeight, index + 1, actualMilk + aCow.milk, actualWeight + aCow.weight, cows + [aCow]), maxProduction(market, maxWeight, i + 1, actualMilk, actualWeight, cows)) else: #no insertamos la vaca actual return maxProduction(market, maxWeight, i + 1, actualMilk, actualWeight, cows) #devolvemos el resultado return [actualMilk, actualWeight, cows]
from max import max import os if __name__ == '__main__': a = 1 b = -1 print(max(a, b)) try: # f_path = os.getcwd() + r"\my_txt.txt" f = open(r"E:\python_program\python_program\test01\my_txt.txt") print(f.read()) f.close() except Exception: os.system("pause") os.system("pause")
def test_two(): assert max([1, 2, 9, 3, 7, 1]) == 9
def test_one(): assert max([1, 2, 3, 7, 1]) == 7
def test_five(): assert max([1]) == 1
def test_four(): assert max([9, 1, 2, 3, 7, 1]) == 9
def test_three(): assert max([1, 2, 3, 7, 1, 9]) == 9
def pos(x): """ Alias for max{x,0}. """ return max(x,0)
def test_list(): assert max.max([2, 1, 5, 4, 7]) == 7
def test_empty(): assert max.max([1]) == 1
def pos(x): return max(x,0)
# import mymodule # print(mymodule.e) # print(mymodule.p) # mymodule.kent_tver() # a = mymodule.person['name'] # print(a) # from mymodule import person # print(person['age']) # import platform # x = platform.system() # print(x) # from factorial import factorial # print(factorial(3)) # from fibonaci import fibonaci # fibonaci(50) from max import max print(max([1, 2, 3]))
import max numbers = [19, 20, 30] print(max.max(numbers))
def pos(x): """ Alias for max{x,0}. """ return max(x, 0)
import max a = raw_input('请输入第一个数字:') b = raw_input('请输入第二个数字:') max.max(a, b)
def test_equal(): assert max.max([1, 1, 1, 1]) == 1
import max a = raw_input("请输入第一个数字:") b = raw_input("请输入第二个数字:") max.max(a, b)