# Respresting data when I have to move back and forth

I am having data where I would be given customers and there priorities. The priority would be food type and there flavours.

In total there are N food type and 2 flavour (spicy and non spicy) so in total there are 2N choices to make.

Each of the customer has a set of food types they like and they are satisfied if there is atleast one of there prefered food types prepared.

There is exactly one food type made with a certain flavour so if we have a spicy food type then we cannot have the same non-spicy food type.

For each customer you make atleast on food type that they like for example there are three customers and they have different food priorities (italian, chinese, meditiranian) and amongst any of it they can choose spicy and non-spicy.

In first case, If the customer 1 has priority that he wants spicy italian and customer 2 wants non-spicy italian then it is not possible

In the second case, If the customer 1 has priority of non-spicy italian, customer 2 has priority of spicy italian and non-spicy chineseand customer 3 has priority of meditaranian spicy. So, this is possible as all the three customer demands can be met.

// n customers
(1st row for 1st customer)// number_of_food food_type non_spicy=0/spicy=1
...


The data for the case 1 would be represented as

2
1 1 0
1 1 1


The date for case 2 would be represented as

3 // customers
1 1 0
2 1 1 2 0
1 3 1


So, finally, the question, how can I represent this data so that I can move/traverse through the data in more efficient way.

Because if I make a certain choice for a customer A and then for a customer B which I encountered further in the list I see that the priority for the customer B is the same as A then I have to move back to customer A and see its other choices and switch him to select other choices and then I have traverse to through the list again moving forward from customer A until customer B.

I am just looking for some hint on this and the name of data structure and algorithm and the reason for choosing that. From that point forward I can look into how it works and code myself.

• This sounds awfully like a programming contest problem... – vonbrand Dec 26 '15 at 0:00