I'm trying to solve the following problem :
A tile results of a number and a color.
- a tile can be black, red, orange or blue.
- a tile number is >= 1 and <= 15.
Given a random set a tiles (a same tile cannot be present more than twice in the set, so we have 15 * 4 * 2 = 120 tiles maximum), find if all the tiles can be grouped in valid subsets at one time.
There are two types of valids subsets :
- The first one is a group. A group is a set of either three or four tiles of the same number but in different colors. (ex. 8 black, 8 red, 8 blue, 8 orange)
- The second is a run. A run is a set of three or more consecutive numbers, all in the same color. (ex. 5 red, 6 red, 7 red).
My first try was a bruteforce/backtracking attempt : find all valid subsets, remove one from the set, find all valid subsets again (backtrack if none found and try another), remove one again ... but there are too many possibilities for my cpu (i7 8700).
How could i solve this problem ?
Thanks for help,