Ok, I tried to read your post and found it too annoying. If you can't bother to take the extra second it will take to write the words "the", "are", "and", and "of", how can you expect other people to take the time to
(a) read your post
(b) think about your problem
(c) take the time to reply with a solution
Note that you are asking other people to donate their time to help you. Show some consideration and put in the extra effort it takes so that people don't have to first decode your post before they know what you're asking.
When I first read your post I thought you were defining variables: "moves in d", "required direction n", "its current position n".
- Ben