Kodewick
Start learning →
Starter←→0 / 60

Enough chairs?

#023Startervector2 min

Everyone at the picnic needs a chair. Write enough_chairs(guests, chairs): guests is who's coming; return true if there are enough chairs and false if not. Nobody coming counts as enough.

Examples
enough_chairs({"Amy", "Bao", "Coco"}, 4)→True
enough_chairs({"Amy", "Bao", "Coco"}, 2)→False
The functionbool enough_chairs(const vector<string> &guests, int chairs)
main.cpp
#include <string>
#include <vector>
using namespace std;

bool enough_chairs(const vector<string> &guests, int chairs) {
    int people = 0;
    // your code here: set people to how many are on the list
    return people <= chairs;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.