Algorithm to solve a Set card game