Rooks can move any number of squares horizontally or vertically on a chess board. The n rooks problem is to arrange rooks on an n×n board in such a way that none of the rooks could bump into another by making any of its possible horizontal or vertical moves.
For this problem, the variables are each column (labeled 0, 1, ... , n−1), the the domain consists of each possible row (also labeled 0, 1, ... ,n−1). In each column we place a rook on row 0, row 1, ... , row n−1.
For example, if n=2 we have only two solutions to this problem:
R @ @ R
or
@ R R @
How many possible solutions are there to this, in terms of
n?
Also, give a simple proof that your answer is correct.
Answer: N! (factorial of N)
Proof: There should be exactly one rook in each column and in each row. If this is not held than there will be at least one pair of rooks attacking each other. We populate each column one by one with rooks. In first column we have N possible position for the rook, as there are no previous rooks and it can be put in any row. After that in second column we have only N-1 valid position, as the one row is already occupied with previous rook. In third column we have N-2 places left as two rows are already occupied by first and second rooks. and so on. In the last Nth column we have only 1 possible position as previous N-1 rooks occupied different N-1 rows and only one is left. So we have N*(N-1)*(N-2)*(N-3)*...*2*1 = N!
Example: If N is equal to 3. In first column we
can put rook in any place (3 variants). In second column one row is
occupied by previous rook so we have only 2 options and in last
column we have 1 option. In total 3*2*1=6 variants.
Rows for each rook:
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
____________________________
Comment down for any queries
Please give a thumb up
Rooks can move any number of squares horizontally or vertically on a chess board. The n...
Eight rooks are placed randomly on a chess board. What is the probability that none of the rooks can capture any of the other rooks? Translation for those who are not familiar with chess: pick 8 unit squares at random from an 8 × 8 square grid. What is the probability that no two chosen squares share a row or a column? Hint. You can think of placing the rooks both with or without order, both approaches work.
Problem 1. How many ways are there to place 8 rooks on a chess board in such a way that they cannot capture each other? Just in case some of you do not know the rules of chess, this is the same as: how many ways can we pick 8 points on an 8x8 grid such that every row and every column has at most one point on it?)
Problem 1. How many ways are there to place 8 rooks...
4. Eight rooks are placed randomly on a chess board. What is the probability that none of the rooks can capture any of the other rooks? (In non-chess terms: Randomly pick 8 unit squares from an 8 x 8 square grid. What is the probability that no two squares share a row or a column?) Hint: How many choices do you have to place rooks in the first row? After you have made your choice, how many choices do you...
King in N moves. In chess, a king can move one space in any of the 8 directions (2 vertical, 2 horizontal, 4 diagonals). Suppose our chessboard is infinite in every direction, and a king starts on a particular square. (a) How many different squares are possible locations for the king after N or fewer moves? (b) Answer the same question for a “crippled king” that can only move horizontally and vertically (no diagonal moves allowed). For both parts, show...
Question 2: Part 1: Show that it is not possible to choose a uniform positive integer at random. (In other words, we cannot define a probability measure on the positive integers that can be considered uniform). Hint: What would be the probability of choosing a particular number? Part 2: Eight rooks are placed randomly on a chess board. What is the probability that none of the rooks can capture any of the other rooks? Translation for those unfamiliar with chess:...
Concepts: multi-dimension array and the Knight's Tour Problem A chess board consists of an 8 x 8 "array" of squares: int board[ROW][COL]={0}; A knight may move perpendicular to the edges of the board, two squares in any of the 4 directions, then one square at right angles to the two-square move. The following lists all 8 possible moves a knight could make from board [3][3]: board[5][4] or board[5][2] or board[4][5] or board[4][1] or board[1][4] or board[1][2] or board[2][5] or board[2][1]...
You're given a chess board with dimension n x n. There's a king at the bottom right square of the board marked with s. The king needs to reach the top left square marked with e. The rest of the squares are labeled either with an integer p (marking a point) or with x marking an obstacle. Note that the king can move up, left and up-left (diagonal) only. Find the maximum points the king can collect and the number...
Please write code in java You’re given a chess board with dimension n x n. There’s a king at the bottom right square of the board marked with s. The king needs to reach the top left square marked with e. The rest of the squares are labeled either with an integer p (marking a point) or with x marking an obstacle. Note that the king can move up, left and up-left (diagonal) only. Find the maximum points the king...
in c++
Purpose: This lab will give you experience
harnessing an existing backtracking algorithm for the eight queens
problem, and seeing its results displayed on your console window
(that is, the location of standard output).
Lab
A mostly complete version of the eight queens problem has been
provided for you to download. This version has the class Queens
nearly completed.
You are to provide missing logic for the class Queens that will
enable it to create a two-dimensional array that...
Please help i need a C++ version of this code and keep getting
java versions. Please C++ only
Purpose: This lab will give you experience
harnessing an existing backtracking algorithm for the eight queens
problem, and seeing its results displayed on your console window
(that is, the location of standard output).
Lab
A mostly complete version of the eight queens problem has been
provided for you to download. This version has the class Queens
nearly completed.
You are to provide...