Question: Using python, Consider an m by n chessboard with the squares labeled (0,0),(0,1),...,(m-1,n-1). 1. Write a function rook_number() which takes in three variables m -

Using python, Consider an m by n chessboard with the squares labeled (0,0),(0,1),...,(m-1,n-1).

1. Write a function rook_number() which takes in three variables m - number of rows n - number of columns k - number of pieces and returns the number of ways that we can place k non-attacking rooks on an m by n chessboard. You might want to have it call a function board() which takes in m and n and returns the set of positions on the board, but you do not need to do so.

>>> rook_number(2,3,3) 0 >>> rook_number(3,3,3) 6 >>> rook_number(3,3,2) 18 >>> rook_number(3,3,1) 9 >>> rook_number(5,5,2) 200

2. Write a function king_number() which does the equivalent for kings. You can use as many functions as you like. It is only the end function king_number() that I will be evaluating.

>>> king_number(3,3,5) 0 >>> king_number(3,3,4) 1 >>> king_number(3,3,3) 8 >>> king_number(3,3,2) 16 >>> king_number(5,5,2) 228

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!