Operation with matrix

-1

I have a list of products and a list of prices of these products by market, so that each market has its basket (basket of products with price).

It happens that I need a function that returns the lowest total list price for two markets combined.

  

Example: a list with 5 distinct products and at least 4 markets   available for sale. How to make, every   the two markets analyzed, calculate the total cost of the list,   taking the lowest price between the two markets.

EXAMPLE :

listCompra = [ product1, product2, product3, product4, product5 ]

What is the lowest total price considering the combination of two markets?

//baskets matrix (Produto, Preço)
supermarket1 = basket1 [     [product1, 10,0]
                            ,[product2, 12,0]
                            ,[product3, 11,0]
                            ,[product4, 9,0]
                            ,[product5, 8,0]  ];

supermarket2 = basket2 [     [product1, 13,0]
                            ,[product2, 11,0]
                            ,[product3, 10,0]
                            ,[product4, 10,0]
                            ,[product5, 9,0]  ];

supermarket3 = basket3 [     [product1, 11,0]
                            ,[product2, 9,0]
                            ,[product3, 12,0]
                            ,[product4, 9,0]
                            ,[product5, 7,0] ];

supermarket4 = basket4 [     [product1, 8,0]
                            ,[product2, 11,0]
                            ,[product3, 9,0]
                            ,[product4, 7,0]
                            ,[product5, 16,0] ];
    
asked by anonymous 18.12.2018 / 18:51

1 answer

0

Each basket has a shopping list, consisting of Product and Value. Each basket represents the value of the list in a market. Imagine that you have to buy 5 products and have already researched the price in the 4 different supermarkets, if you can go to two supermarkets which would be the two to be chosen? Being the criterion the lowest total price of the list.

    
20.12.2018 / 09:27