# All possible placements of n mirrors in a grid

Printable View

• 05-06-2012, 12:26 PM
Lucato
All possible placements of n mirrors in a grid
Hello everyone,

For an assignment from school we have to build a grid and find a correct placement of mirrors in the grid
so that light would come in at one cel (of the grid) and leave at another cel.

Now my idea was to build a grid, place numbers around it for in and out,
and check for any set up of mirrors if it is correct.
If a set up is correct it is returned and the program terminates.
I did most of this, i.e. I can check for a given positioning of mirrors if it is correct given the in and out. But now I am stuck on how to generate all the possible positionings given a grid and n mirrors.

Can anyone give me tips on how to do this?
I was thinking of 2D arrays that store either -1, 0, or 1 in each array location
(-1 for / , 0 for nothing and 1 for \). The problem is finding a way to generate all possible combinations of
-1, 0 and 1 in such 2D array.

Greets,
Lucato