Same Ingredients?

Python for AIMedium+10 XP+10

Same Ingredients?

Two recipes list their ingredients in different orders, and sometimes an ingredient is written twice.

Task: write same_ingredients(recipe_a, recipe_b). Return True if the two recipes use exactly the same different ingredients, and False otherwise.

  • Order doesn't matter.
  • Repeats don't matter: ["egg", "egg", "milk"] uses the same ingredients as ["milk", "egg"].
  • Two empty recipes count as the same.

Examples

recipe_a = ["egg", "egg", "milk"]
recipe_b = ["milk", "egg"]
returns True
recipe_a = ["egg", "milk"]
recipe_b = ["egg", "flour"]
returns False

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run