There's a game you play with tiles which each can be represented by a number within the [1, 9] range. You are given a list of 13 tiles. Now you try to pick another tile to make it a winning hand. We call this tile a winning tile.
A winning hand is when the 14 tiles can be grouped into 4 valid triples and 1 pair, where a valid triple is either 3 of a kind, or 3 consecutive numbers.
Some examples of winning states:
11223344555999 -> 123|123|555|999|44
11122345678999 -> 111|345|678|999|22
22455666777889 -> 456|567|678|789|22
The task is to print out all such winning tiles.
Example:
Input: "111667788899"
Output: [7, 8, 9]
Explanation:
111667788899 + 7 -> 1116677788899 -> 111|666|777|888|99
111667788899 + 8 -> 1116677888899 -> 111|666|789|789|88
111667788899 + 9 -> 1116677888999 -> 111|666|888|999|77