Welcome to MSDN Blogs Sign in | Join | Help
Contest: Of Knights and Mazes

This week’s contest is to direct a chess knight around a maze. Your job is to find the exit by only using knight moves and by not moving over any walls. The knight must land on the exit to exit the maze. Rules

Implement the following function given the prototypes:

bool IsWall(int x, int y);

bool IsExit(int x, int y); 

bool RunTheMaze()

{

      // Knight always starts at 0,0

      // Knight may not move over or land on a wall.

      // Knight always moves in the 2x1 L pattern like a chess knight

      // Knight must land on the exit to win

      // Return true when you've found the exit or false if you can’t get there

      // Make a good trade off between memory and performance

      // Objective is to find the exit or determine you can't get it to it,

      // not find the least number of moves to get there.

      // You may use any collection classes you deem necessary

      // ‘int’ is a 32-bit signed integer

}

 

Posted: Monday, April 16, 2007 5:00 PM by Chris Becker
Filed under:

Comments

Daniel said:

You can't move _over_ a wall or you can't _land_ on any walls?

# April 16, 2007 7:17 PM

Chris Becker said:

A wall cannot be in your path to the next move, the knight can't jump the wall.

# April 16, 2007 7:22 PM

Jack said:

Looks like the maze is always bounded by a wall. Does that mean, for example,  IsWall(-1, -1)  is a legal call and returns true?

# April 16, 2007 9:16 PM

Chris Becker said:

Yes, the maze will be bounded, negative position coordinates are perfectly valid.

# April 16, 2007 10:37 PM

Nick Q said:

I just want to make sure...you want a general solution for this problem? It seems like the one for the image you posted with the 2 starting points seems pretty simple.

If it is a general solution, could you give us a maximum  "world" size? Maybe 10x10? (your image would be 5x6)

# April 18, 2007 10:42 PM

Chris Becker said:

Correct, a general solution. The maze will be bounded, but I didn't specify a maximum size.

# April 19, 2007 2:39 PM

CoolBeans: From College to Industry said:

There were a few less takers for this one than the others, it seems the complexity of the problem may

# April 30, 2007 6:01 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker