Now that you’ve isolated the inert ingredients, you should have enough information to figure out which ingredient contains which allergen.

In the above example:

Arrange the ingredients alphabetically by their allergen and separate them by commas to produce your canonical dangerous ingredient list. (There should not be any spaces in your canonical dangerous ingredient list.) In the above example, this would be mxmxvkd,sqjhc,fvjkl.

Assignment

Time to stock your raft with supplies. What is your canonical dangerous ingredient list? Determine this in the following way:

Example

In this interactive session we assume the text file food.txt1 to be located in the current directory.

> dangerousIngredients("foods.txt")
'mxmxvkd,sqjhc,fvjkl'