Problem Description
We all love a Twix (because it is the best candy), but this is the kids' first Halloween --- we gotta grab at least one of each type of candy for them. Each Halloween all the residents of Numberline avenue send out an email saying what types of candy they'll be giving away this year.
Oh! And we live in a 1D world.
Being exceptionally lazy in some ways and not in others, we've made a map of the houses giving their positions along the street. We also noted the types of candy they have. Here's the map we made for this year:
[(-2, {"Kisses", "KitKats"}),
(1, {"KitKats", "Peanut Butter Cups"}),
(6, {"Kisses", "Twix"}),
(9, {"Skittles"}),
(10, {"Twix"})]
For the sake of the kids' little legs, we need to find the shortest walk starting at any house in the neighborhood to gather at least one of each type of candy.
Examples
At the request of a couple users (including Shaggy), I'll toss in some worked examples. Hopefully this clears things up. :) Input:
[(-2, {"Kisses", "KitKats"}),
(1, {"KitKats", "Peanut Butter Cups"}),
(6, {"Kisses", "Twix"}),
(9, {"Skittles"}),
(10, {"Twix"})]
Output:
[1, 2, 3]
Another map and solution...
Input:
[(-3, {"KitKats", "Twix"}),
(-1, {"Hundred Grands"}),
(3, {"Kisses"}),
(12, {"Hundred Grands", "Twix", "KitKats"})]
Output:
[0, 1, 2]
We could begin at the coordinate 9 house collecting candies to at houses 6 and 1. That fills the candy quota by walking 8 units, but is it the shortest solution?
Rules
Entries must take in a similarly structured single argument to the example and output the indices of the houses to visit in the shortest solution.
Typical code golf rules apply: shortest correct solution in bytes wins!
P.S. This was an interview question given to me by one of the world's largest tech companies. If you don't like golf, try finding an O(k*n) time solution where k is the number of candy types and n is the number of houses.
Edit
As Jonathon Allan pointed out, some confusion exists around what "indices" means in this case. We want to output the houses positions in the argument list and not their coordinates on the lane.