コード例 #1
0
ファイル: shopSmart.py プロジェクト: njittam/aib
def shopSmart2(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    priceList = [shop.getPriceOfOrder(orderList) for shop in fruitShops] # a list with al the total prices of shops in fruitShops
    return [shop for shop in fruitShops if shop.getPriceOfOrder(orderList) == min(priceList)][0] # a list of all the shops with the lowest price and return the first
コード例 #2
0
ファイル: shopSmart.py プロジェクト: Andrea-Cv/IA
def shopSmart(orderList, fruitShops):
    menor = fruitShops[0].getPriceOfOrder(orderList)
    tienda = fruitShops[0]
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < menor:
            menor = shop.getPriceOfOrder(orderList)
            tienda = shop
        else:
            None
    return tienda
コード例 #3
0
ファイル: shopSmart.py プロジェクト: ChristopherKai/ai
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    num = fruitShops[0].getPriceOfOrder(orderList)
    name = fruitShops[0]
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) <= num:
            num = shop.getPriceOfOrder(orderList)
            name = shop
    return name
コード例 #4
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    output = fruitShops[0]
    min = output.getPriceOfOrder(orderList)
    for shop in fruitShops[1:]:
        if shop.getPriceOfOrder(orderList) < min:
            output = shop
            min = shop.getPriceOfOrder(orderList)
    return output
コード例 #5
0
ファイル: shopSmart.py プロジェクト: JesseGrootjen/INFOB2KI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    cost = 1000.0
    for shop in fruitShops:
        if cost > shop.getPriceOfOrder(orderList):
            cost = shop.getPriceOfOrder(orderList)
            cheapest = shop
    return cheapest
コード例 #6
0
ファイル: shopSmart.py プロジェクト: JackieHo10/CSCI3202
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    Best = fruitShops[0]
    Lowest = fruitShops[0].getPriceOfOrder(orderList)
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < Lowest:
            Best = shop
            Lowest = shop.getPriceOfOrder(orderList)
    return Best
コード例 #7
0
ファイル: shopSmart.py プロジェクト: JBBot11/Proyecto-0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    best_price = fruitShops[0].getPriceOfOrder(orderList)
    best_shop = fruitShops[0]
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < best_price:
            best_price = shop.getPriceOfOrder(orderList)
            best_shop = shop
    return best_shop
コード例 #8
0
ファイル: shopSmart.py プロジェクト: TeemosCode/Python
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    shopPrice = 100000000  #Does python have an Infinite KEYWORD???
    for shop in fruitShops:
        if shopPrice > shop.getPriceOfOrder(orderList):
            bestShop = shop
            shopPrice = shop.getPriceOfOrder(orderList)
    return bestShop
コード例 #9
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    minCost = 100000000000000;
    minShop = None;
    for shop in fruitShops:
      if shop.getPriceOfOrder(orderList) < minCost:
        minShop = shop
        minCost = shop.getPriceOfOrder(orderList)

    return minShop
コード例 #10
0
ファイル: shopSmart.py プロジェクト: leoleblanc/CS188
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    chosen_shop = fruitShops[0] #set the first shop as default
    cost = fruitShops[0].getPriceOfOrder(orderList)
    for shop in fruitShops:
      if shop.getPriceOfOrder(orderList) < cost:
        chosen_shop = shop
        cost = shop.getPriceOfOrder(orderList)
    return chosen_shop
コード例 #11
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    cost = fruitShops[0].getPriceOfOrder
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < cost :
            cost = shop.getPriceOfOrder(orderList)
            optimalShop = shop

    return optimalShop
コード例 #12
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    minCost = None
    minShop = None
    for shop in fruitShops:
      if shop.getPriceOfOrder(orderList) < minCost or minCost == None:
        minCost = shop.getPriceOfOrder(orderList)
        minShop = shop
    return minShop
コード例 #13
0
ファイル: shopSmart.py プロジェクト: anhvqle/PACMAN_AI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    bestShop = fruitShops[0]
    lowestCost = bestShop.getPriceOfOrder(orderList)
    for shop in fruitShops[1:]:
        if shop.getPriceOfOrder(orderList) < lowestCost:
            lowestCost = shop.getPriceOfOrder(orderList)
            bestShop = shop
    return bestShop
コード例 #14
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    cost = 1000000
    bestShop = None
    for i in range(len(fruitShops)):
        shop = fruitShops[i]
        if (shop.getPriceOfOrder(orderList) < cost):
            cost = shop.getPriceOfOrder(orderList)
            bestShop = shop
    return bestShop
コード例 #15
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    menor = fruitShops[0].getPriceOfOrder(orderList)
    tienda = fruitShops[0]
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < menor:
            menor = shop.getPriceOfOrder(orderList)
            tienda = shop
        else:
            None
    return tienda
コード例 #16
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    orderCost = float('inf')
    cheapestShop = ""
    # Iterate over all the shops, if the cost of the order is cheaper
    # then set orderCost and cheapestShop to the one we found
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < orderCost:
            orderCost = shop.getPriceOfOrder(orderList)
            cheapestShop = shop
    return cheapestShop
コード例 #17
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    minCost = fruitShops[0].getPriceOfOrder(orderList)
    bestShop = fruitShops[0]

    for shop in fruitShops[1:]:
        if shop.getPriceOfOrder(orderList) < minCost:
            bestShop = shop
            minCost = shop.getPriceOfOrder(orderList)

    return bestShop
コード例 #18
0
ファイル: shopSmart.py プロジェクト: DuncanBauer/cs140
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    orderPrice = 0.0
    bestPrice = 99999
    best = "shop1"
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < bestPrice:
            bestPrice = shop.getPriceOfOrder(orderList)
            best = shop
    return best
コード例 #19
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    returnShop = fruitShops[0]
    currentBudget: float = returnShop.getPriceOfOrder(orderList)
    for shop in fruitShops[1:]:
        print(currentBudget)
        print(shop.getPriceOfOrder(orderList))
        if shop.getPriceOfOrder(orderList) < currentBudget:
            returnShop = shop
    return returnShop
コード例 #20
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    bestPrice=-1 
    for shop in fruitShops: 
        if bestPrice==-1:
            bestPrice=shop.getPriceOfOrder(orderList)
            bestShop=shop
	elif shop.getPriceOfOrder(orderList)<bestPrice:
            bestPrice=shop.getPriceOfOrder(orderList)
            bestShop=shop
    return bestShop
コード例 #21
0
ファイル: shopSmart.py プロジェクト: phuzii/Project0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    bestCost = None
    bestShop = fruitShops[0]
    for shop in fruitShops:
        costOfOrderAtShop = shop.getPriceOfOrder(orderList)
        if bestCost is None:
            bestCost = shop.getPriceOfOrder(orderList)
        if costOfOrderAtShop < bestCost:
            bestShop = shop
    return bestShop
コード例 #22
0
ファイル: shopSmart.py プロジェクト: MetricVoid/CS3600
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    current_price = None
    best_shop = None
    for shop in shops:
        if current_price is None:
            current_price = shop.getPriceOfOrder(orderList)
            best_shop = shop
        if (shop.getPriceOfOrder(orderList) < current_price) and (current_price is not None):
            best_shop = shop
    return best_shop
コード例 #23
0
ファイル: shopSmart.py プロジェクト: alexniarchos/AI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    # initialize minimum total cost
    minTotalCost = fruitShops[0].getPriceOfOrder(orderList)
    # initialize cheapest shop
    cheapShop = fruitShops[0]
    # find actual cheapest shop
    for shop in fruitShops:
        if (shop.getPriceOfOrder(orderList) < minTotalCost):
            minTotalCost = shop.getPriceOfOrder(orderList)
            cheapShop = shop
    return cheapShop
コード例 #24
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    cheapest_shop = None
    cheapest_shop = fruitShops[0]
    cheapest_price = 9999
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) < cheapest_shop.getPriceOfOrder(
                orderList):
            cheapest_price = shop.getPriceOfOrder(orderList)
            cheapest_shop = shop
    return cheapest_shop
コード例 #25
0
ファイル: shopSmart.py プロジェクト: jeroenhd/ProjectSkynet
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """

    bestShop = None
    bestPrice = 0

    for shop in fruitShops:
        if bestPrice == 0 or shop.getPriceOfOrder(orderList) < bestPrice:
            bestShop = shop
            bestPrice = shop.getPriceOfOrder(orderList)

    return bestShop
コード例 #26
0
ファイル: shopSmart.py プロジェクト: vietlinhtspt/cs188
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    price = fruitShops[0].getPriceOfOrder(orderList)
    shop_return = fruitShops[0]

    for shop in fruitShops:
        if price > shop.getPriceOfOrder(orderList):
            price = shop.getPriceOfOrder(orderList)
            shop_return = shop

    return shop_return
コード例 #27
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    prices = [shop.getPriceOfOrder(orderList) for shop in fruitShops]
    return fruitShops[prices.index(min(prices))]
コード例 #28
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """

    return min(fruitShops, key = lambda shop: shop.getPriceOfOrder(orderList))
コード例 #29
0
ファイル: shopSmart .py プロジェクト: omnibox/spring2016cs540
def shopSmart(orderList, fruitShops):
    min_cost, minimum = None, None
    for shop in fruitShops:
           cost = shop.getPriceOfOrder(orderList)
           if min_cost == None or cost < min_cost:
                min_cost, minimum = cost, shop
    return minimum
コード例 #30
0
def shopSmart(orderList, fruitShops):
    mcost, itmin = None, None
    for shop in fruitShops:
        cost = shop.getPriceOfOrder(orderList)
        if mcost == None or cost < mcost:
            mcost, itmin = cost, shop
    return itmin
コード例 #31
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    amountsByShops = [(shop.getPriceOfOrder(orderList), shop)for shop in fruitShops]
    return sorted(amountsByShops)[0][1]
コード例 #32
0
ファイル: shopSmart.py プロジェクト: KengoWada/CSC2114
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    return min(fruitShops, key=lambda shop: shop.getPriceOfOrder(orderList))
コード例 #33
0
ファイル: shopSmart.py プロジェクト: CarlosMa15/AI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"

    # The answer to our problem
    answer = None

    # The min price
    minPrice = float("inf")

    # iterating through the price
    for shop in fruitShops:

        # The price per shop
        price = shop.getPriceOfOrder(orderList)

        # Checks if its the first shop
        if answer == None:
            answer = shop
            minPrice = price

        # Checks if it is a shop with a lower price
        elif price < minPrice:
            answer = shop
            minPrice = price

    # return results
    return answer
コード例 #34
0
ファイル: shopSmart.py プロジェクト: bashwork/school
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"
    return min((shop.getPriceOfOrder(orderList), shop)
        for shop in fruitShops)[1]
コード例 #35
0
ファイル: shopSmart.py プロジェクト: yiweig/cs325
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    

    # sort the list from least to most expensive and return the first element
    return sorted(fruitShops, key = lambda shop: shop.getPriceOfOrder(orderList))[0]
コード例 #36
0
ファイル: shopSmart.py プロジェクト: bflynn14/school
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    return min(
        (shop.getPriceOfOrder(orderList), shop) for shop in fruitShops)[1]
コード例 #37
0
ファイル: shopSmart.py プロジェクト: TheBryant/188
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    bestShop = {}
    for shop in fruitShops:
        bestShop[shop.getPriceOfOrder(orderList)] = shop
    return bestShop[min(bestShop.keys())]
コード例 #38
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    cost = 0
    for shop in fruitShops:
        if cost == 0:
            cost = shop.getPriceOfOrder(orderList)
            shopname = shop

        else:
            if shop.getPriceOfOrder(orderList) < cost:
                cost = shop.getPriceOfOrder(orderList)
                shopname = shop

    return shopname
コード例 #39
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    minOrderPrice = fruitShops[0].getPriceOfOrder(orderList)
    lowest = lambda cheapestShop, shop: shop if shop.getPriceOfOrder(
        orderList) < minOrderPrice else cheapestShop
    return reduce(lowest, fruitShops[1:], fruitShops[0])
コード例 #40
0
ファイル: shopSmart.py プロジェクト: kafeak/edxai
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    evaluatedShops={}
    for shop in fruitShops:
        evaluatedShops[shop]=shop.getPriceOfOrder(orderList)
    evaluatedShops=OrderedDict(sorted(evaluatedShops.items(), key=lambda t: t[1]))
    return evaluatedShops.keys()[0]
コード例 #41
0
ファイル: shopSmart.py プロジェクト: chashao/CS188
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    prices = []
    for shop in fruitShops:
      prices.append(shop.getPriceOfOrder(orderList))
    return fruitShops[prices.index(min(prices))]
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"
    totalPriceList = []
    for shop in fruitShops:
      totalPriceList.append(shop.getPriceOfOrder(orderList))
    return fruitShops[totalPriceList.index(min(totalPriceList))]
コード例 #43
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"
    Fruit = [] #list for holding fruit
    for shop in fruitShops: #looping through different shops in fruitShops
      FruitPrice = (shop.getPriceOfOrder(orderList), shop)#gathering the prices and the shops associated with those prices by containing them in a tuple
      Fruit.append(FruitPrice)#appends the prices to Fruit[]
    return min(Fruit)[1]#returns the shop with the minimum value which will be in the (price, shop) [1] spot
コード例 #44
0
ファイル: shopSmart.py プロジェクト: alwasa0b/school
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    minimum,deal=None,None
    for shop in fruitShops:
        totalCost = shop.getPriceOfOrder(orderList)
        if totalCost < minimum or minimum==None:
            minimum, deal = totalCost, shop
    return deal
コード例 #45
0
ファイル: shopSmart.py プロジェクト: DavidMcDonnel/cse511
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"
    shopDict = {}
    for shop in fruitShops:
        shopDict[shop] = shop.getPriceOfOrder(orderList)
    ans = min(shopDict,key=shopDict.get)
    return ans
コード例 #46
0
ファイル: shopSmart.py プロジェクト: seanxwh/github
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    bestStore=None
    for shop in fruitShops:
        if (bestStore==None):
            bestStore=shop
        elif(bestStore!=None):
            bestStore=shop if shop.getPriceOfOrder(orderList)<bestStore.getPriceOfOrder(orderList) else bestStore
    return bestStore
コード例 #47
0
ファイル: shopSmart.py プロジェクト: cybermaster/AI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"

    fruitshop = fruitShops[0]
    for shop in fruitShops:
        if shop.getPriceOfOrder(orderList) <= fruitshop.getPriceOfOrder(orderList):
            fruitshop = shop
    return fruitshop
コード例 #48
0
ファイル: shopSmart.py プロジェクト: joshfermin/AI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"
    smallestCost, cheapestShop = None, None
    for shop in fruitShops:
        cost = shop.getPriceOfOrder(orderList)
        if smallestCost == None or cost < smallestCost:
            smallestCost, cheapestShop = cost, shop
    return cheapestShop
コード例 #49
0
ファイル: shopSmart.py プロジェクト: douglasguo/CS188.1X
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    min = float('inf')
    for shop in fruitShops:
        price = shop.getPriceOfOrder(orderList)
        if price < min:
            min = price
            cheapest = shop
    return cheapest
コード例 #50
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    "*** YOUR CODE HERE ***"
    totalCosts = []
    for shop in fruitShops:
      totalCosts.append((shop, shop.getPriceOfOrder(orderList)))

    totalCosts = sorted(totalCosts, key=itemgetter(1))
    return totalCosts[0][0]
コード例 #51
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """ 
    leastExpensive = 9999999.0
    for shop in fruitShops:
        currentOrderPrice = shop.getPriceOfOrder(orderList)
        if currentOrderPrice < leastExpensive:
            leastExpensive = currentOrderPrice
            bestShop = shop
    return bestShop
コード例 #52
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    bestShopPrice = fruitShops[0].getPriceOfOrder(orderList)
    bestShopName = fruitShops[0]
    for shop in fruitShops:
        currentPrice = shop.getPriceOfOrder(orderList)
        if currentPrice < bestShopPrice:
            bestShopPrice = currentPrice
            bestShopName = shop
    return bestShopName
コード例 #53
0
ファイル: shopSmart.py プロジェクト: njittam/aib
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    #return shopSmart2(orderList, fruitShops)
    cheapest_price = fruitShops[0].getPriceOfOrder(orderList)  # Cheapest price holds the current lowest price
    for shop in fruitShops:
        price = shop.getPriceOfOrder(orderList)  # price is the current price to be checked
        if price <= cheapest_price:  # if price is lower remember the shop and the according price
            cheapest_price = price
            cheapest_shop = shop
    return cheapest_shop
コード例 #54
0
ファイル: shopSmart.py プロジェクト: gshalev/edx_courses
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    minOrderCost = None
    minShop = None
    for shop in fruitShops:
        currOrderCost = shop.getPriceOfOrder(orderList)
        if currOrderCost < minOrderCost or minOrderCost == None:
            minShop = shop
            minOrderCost = currOrderCost
    return minShop
コード例 #55
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    cheapestShop = None
    cheapestCost = None
    for shop in fruitShops:
        cost = shop.getPriceOfOrder(orderList)
        if cheapestCost == None or cost < cheapestCost:
            cheapestShop = shop
            cheapestCost = cost
    return cheapestShop
コード例 #56
0
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"
    minimum = fruitShops[0].getPriceOfOrder(orderList)
    for shop in fruitShops:
        price = shop.getPriceOfOrder(orderList)
        if price <= minimum:
            bestShop = shop
            minimum = price
    return bestShop
コード例 #57
0
ファイル: shopSmart.py プロジェクト: sgkadle/CSCI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """    
    "*** YOUR CODE HERE ***"

    minCost, argMin = None, None
    for shop in fruitShops:
        cost = shop.getPriceOfOrder(orderList)
        if minCost == None or cost < minCost:
            minCost, argMin = cost, shop
    return argMin
コード例 #58
0
ファイル: shopSmart.py プロジェクト: lucasosouza/berkeleyAI
def shopSmart(orderList, fruitShops):
    """
        orderList: List of (fruit, numPound) tuples
        fruitShops: List of FruitShops
    """
    min = 0
    cheapestShop = ""
    for shop in fruitShops:
      current = shop.getPriceOfOrder(orderList)
      if min == 0 or min > current:
        min = current
        cheapestShop = shop 
    return cheapestShop
コード例 #59
0
ファイル: shopSmart.py プロジェクト: mandary/AI-Pacman
def shopSmart(orderList, fruitShops):
	if fruitShops:
		shopPrices = fruitShops[0].getPriceOfOrder(orderList)
		cshop = fruitShops[0]
		for shop in fruitShops:
			temp = shop.getPriceOfOrder(orderList)
			if temp < shopPrices:
				shopPrices = temp
				cshop = shop
		print "For orders ", orderList, ", the best shop is", cshop.getName()
		return cshop
	else:
		return None