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:
mxmxvkd
contains dairy
.sqjhc
contains fish
.fvjkl
contains soy
.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
.
Time to stock your raft with supplies. What is your canonical dangerous ingredient list? Determine this in the following way:
dangerousIngredients
that takes the pathname (String
) of a text file containing a list of foods. The function must return the canonical dangerous ingredient list (String
) of the list of foods.In this interactive session we assume the text file food.txt
1 to be located in the current directory.
> dangerousIngredients "foods.txt"
'mxmxvkd,sqjhc,fvjkl'