House Party

cehsu
111 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

The goal today is to write a function that returns the min cost of catering all house parties. There are three types of snacks available with the cost of each being different at each house. The costs are all positive and are represented by an n * 3 cost matrix of all the houses (For example, costs[0][0] is the cost of feeding house 0 with snack ceviche; costs[1][2] is the cost of feeding house 1 with snack samosas, and so on...). No two adjacent house parties may have the same hors d'oeuvres, because everyone wants to think their party is the better than the one next door.

Check for the minimum cost

Write an getMin function that takes a n * 3 matrix as a parameter and returns the minimum catering cost.

Write the getMin function
1
2
3
4
5
6
7
8
function getMin (costs) {
// Your code here:
}
module.exports = getMin;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content