I am looking for help in either the math needed or algorithm needed to solve the following problem.

A GearBox consists of an 8x8 grid. The columns are labeled A-H. Rows are labeled 1-8. You are able to place up to 15 shafts, that can hold up to 3 gears per shaft.

Gears come in the following sizes: 1,3,4,5,6,7. To mesh gears and not jam up the gearbox you must follow the following rules:

1 space orthogonally: Must add to 6 -- only 1 combination 3-gear with a 3-gear (eg. A1- A2 or G3-H3)

1 space diagonlly: Must add to 8 (4-4, 5-3, 3-5) (A1-B2)

2 spaces orthogonally: Must add to 11

Knight's Move: Must add to 12

Size 1 gears are purely spacers to stack gears they don't mesh with anything.

Note: If gears are too far apart (B1 has a 4 gear, and B3 has a 4 gear) nothing happens, B3 just doesn't turn. But if they are too close (B1 has 6 Gear, B2 has a 5 gear) then the GearBox will jam and is illegal.

A1 is always the input space. It turns at 100%. A8-H8 are the output spaces. A problem will include a list of required output like this:

A 300-343 G 201-252

This means that A8 must turn at some ratio between 300% and 343% of A1, and G8 must turn at some ratio between 201% and 252% of A1.

For Example if you place a 5 gear in A1 and a 3 gear in B2. A1 will be turning at 100% and B2 will be turning at 166%. If you place an addition 6 gear in B2 (on top of the 3 gear), then in space B4 you could place a 1 gear (spacer) then a 5 gear on top it, it will mesh with the 6 gear. this will cause B4 to turn at 200% (5/3 * 6/5).

A very trivial example : D 120-180. The notation (A3:4,5) means place a 4 gear in A3, than a 5 gear on top of the 4 gear.

(A1:4),(B2:4),(C3:4), (D4:4),(E5:4),(D6:4),(E7:4,5),(D8:1,3) D8 is now turning at 166%

A GearBox requirement will always be 2 or 3 output nodes of the form (0ut1 - Out2) where 0 < Out1 < 1000 and Range (0ut2-Out1) is between 40 and 60.

I'm not even sure what maths will would be needed to solve this problem, or how to setup the problem programmatically. I assume it will require setting up a tree of some sort, and searching through nodes to find a solution. Any help would be appreciated.