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] ];