Sorting data in to groups based on rules
Hi there, Iâm wondering if anyone here could give me some help. Ive been stuck on this problem for weeks and im not getting any closer to solving it, so I hope someone here might be able to point me in the right direction!
I have to write a program to sort some data in to pairs, which normally would be quite simple, but unfortunaly its proving to be rather difficult.
The rules are:
There are 36 items. These items all have a colour and a class.
There are 4 catagorys, these catagorys contain pairs of items:
⢠Each item has to be in every category
⢠Each item can only be in a category once.
⢠An item cannot be paired with another item the same colour
⢠An item cannot be paired with another item in the came class
⢠An item can only be paired with another item once. So if item 2 is with item 36 in category one, they can never be together again.
Well, thatâs quite easy to manage if each class was the same. But because the classes are uneven sizes, its proving very difficult to get them arranged. An example of the data is given below.
Class 1
Item1 Yellow
Item2 Green
Item3 Yellow
Item4 Green
Item5 Yellow
Item6 Green
Class2
Item7 Green
Item8 Yellow
Item9 Green
Item10 Yellow
Class 3
Item11 Green
Item12 Yellow
Item13 Green
Item14 Yellow
Item15 Green
Item16 Yellow
Class 4
Item17 Green
Item18 Yellow
Item19 Green
Item20 Yellow
Item21 Green
Item22 Yellow
Item23 Green
Item24 Yellow
Class 5
Item25 Green
Item26 Yellow
Item27 Green
Item28 Yellow
Item29 Green
Item30 Yellow
Class 6
Item31 Green
Item32 Yellow
Item33 Green
Item34 Yellow
Item35 Green
Item36 Yellow
Anyways, Thanks for you time, if you can think of anything that might help, please let me know!
|