Skip to content

[Practice] Grouping Dishes by Ingredient #37

@lpatmo

Description

@lpatmo

//DISHES
//Each element is a list of strings beginning with the name, followed by ingredients
//Group by ingredient so you can find all the dishes that contain it.
//Only ingredients that are in two or more dishes matter.
//Return an array structured the same way, but with ingredients first and all the dishes after

/*
dishes = [["Salad", "Tomato", "Cucumber", "Salad", "Sauce"],
["Pizza", "Tomato", "Sausage", "Sauce", "Dough"],
["Quesadilla", "Chicken", "Cheese", "Sauce"],
["Sandwich", "Salad", "Bread", "Tomato", "Cheese"]]

groupingDishes(dishes) = [["Cheese", "Quesadilla", "Sandwich"],
["Salad", "Salad", "Sandwich"],
["Sauce", "Pizza", "Quesadilla", "Salad"],
["Tomato", "Pizza", "Salad", "Sandwich"]]

//EC: alphabetical order

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions