Hello, I am working on a project and am trying to finalize some of the more difficult math work. This is based off of a card game "Challenge 24"

The basic premise is you are given 4 numbers (1-9) and you must perform any of the basic mathematical operations in order to produce "24" from those numbers. As an example:

Given 8 2 6 4

8 x 4 = 32; 32 - 6 = 26; 26 - 2 = 24

OR

4 / 2 = 2; 6 / 2 = 3; 8 * 3 = 24 (note all numbers must be used)

As you can see the number of solutions can get large rather quickly. I am trying to determine the best way of A: making sure that the numbers generated HAVE a solution (i.e. 1 1 1 1 cannot come up) and B: enumerating all possible solutions for every 4-number combination without repetition (i.e. 4 4 6 8 is the same as 4 6 4 8; order does not matter).

Thanks for your help