Quick actions

cmd+k|ctrl+k

Navigation

Languages

Challenge: Assemble furniture

Snippet info

Language

JavaScript

Visibility

public

Author

noemi-techfems

Created

2024-09-06T17:50:54.916899Z

Updated

2024-09-06T17:51:06.525134Z

// Here's the explanation of the challenge -- when you're done reading it,
// click on `main.js` above to get started with the challenge!

// After a trip down to the furniture store, you've come back with... well,
// a random collection of pieces of wood and bits of metal, it seems.
// Apparently you have to assemble it yourself. Let's use code to see if we
// can make a dining space out of this.

// ## Description

// In this challenge, you will write a `maximumGuests` function that receives
// two arguments. The first argument is the number of wooden boards, and the
// second argument is the number of wooden legs. The arguments represent the
// pieces we can use to assemble dining tables and chairs.

// For example, if we have four wooden boards and ten wooden legs, the
// function could be invoked like:

// maximumGuests(4, 10)

// Your function should return the number of people that will be able to sit
// around the tables, once the furniture is assembled in the way that allows
// the most people to sit in it.

// For someone to be able to sit around a table, there has to be a **chair**
// for them to sit on, and a **space** in the table for them to sit in front
// of. Here's what you need to know about the furniture:

// To assemble a **table**, you will need **four wooden boards** and **four
// wooden legs**. Each table provides spaces to seat **four people** around
// them, provided there's a chair.

// To assemble a **chair**, you will need **one wooden board** and **three
// wooden legs**. Each chair can sit **one person**, provided there's space
// for them in a table.

// ## Example

// For example, if you have eight wooden boards and twelve wooden legs, you could
// assemble four chairs (with four boards to spare) but then no one would be able
// to sit around the table, because there wouldn't be any tables. You could also
// assemble two tables (with four legs to spare) but then no one would be able
// to sit around those tables either, because there wouldn't be any chairs.

// But with the same boards and legs, you can instead assemble a table and two
// chairs (with two boards and two legs to spare) and sit two people around a
// table. This is the most people you can sit around a table with that number
// of boards and legs, and therefore your function should return `2`.
INFO