Assignment 2 (JAVA)

N-Queens Problem

Description :
The N queens need to be placed on the N x N chess board such that no queen is on the attack of any other queen.

Instructions to run the sample program
  • Download the file Queens.java and compile using the command javac Queens.java
  • Download the file Queens.html and open it from the browser. Enter the dimension N of the chess borad and press "Next" button to view the various ways in which the Queens can placed in the N x N chess board

Download
Queens.java
Queens.html

Assignment
First Part.
Modify the code
  • To change the colour of the queens from Red to Green
  • To represent the queens by numbers instead of dots

Second part

Solve the touring knights problem as decribed below :

User will specify the dimension N of the chess board and will give a starting position of the Knight on it. The program should move the Knight to unvisited squares until it comes to a position from where it is not possible to move to any unvisited square.

It will be nice if you can make the knight visit all places without backtracking. However it is NOT necessary.