I'm working on a turn based strategy game, and I need some help with determining if a given movement is possible.

here's how it goes: when the script to determine possibility is run, we know where the target square is, so I know how many moves up/down and how many over need to be made. What I need to do with that is figure out every order that these moves could be made in. For example, say I have to go over once and up twice. I know the possible combinations are up up over, up over up, and over up up. However, I can't seem to write a script that makes the computer figure it out. What I need is help to write a script that uses the two givens (moves over, moves up/down) and figures out every possibile order of moves. I would be very greatly appreciative of any help that any of you can give me.