Question: Module 5 Homework - Recursion Use recursion to determine if a knight starting in a given square on a chessboard can capture all pawns on
Module Homework Recursion
Use recursion to determine if a knight starting in a given square on a chessboard can capture all pawns on that board using only moves that capture a pawn moves to spaces without a pawn, or spaces with pawns that have already been captured, are not allowed
Consider an x chessboard with a knight and some pawns:#
# Row : # p
# p p
# k
# p
# p
# p
#Row :
kidx
pidxs
# Initial knight index
# Set of pawn indices
This board is solveable. Our knight can capture all pawns with consecutive moves:
However, the following board is not solveable:#
# Row : #
# p p
# k
# p
# p
# p
#Row :
kidx # Initial knight index pidxs # Set of pawn indices
There is no way for our knight to capture all pawns in just moves.
Deliverables
Write Unittests
Use TDD on this assignment write a test, run it then implement functionality. You will be graded on your tests. Starter code for TestHwpy includes some guidance on tests. Do not use the examples above as boards in your tests.
There are no visible autograder tests on this assignment. We have a few hidden tests to help speed up manual grading, but they will not directly impact your grade.
Implment validmoveskidx
validmoveskidx returns a set of tuples representing all valid moves for a knight at kidx.
Implement solveablepidxs, kidx:
pidxs a set of tuples representing pawn locations
kidx a tuple representing the starting position of a knight
Return a boolean denoting whether the passed in pidxs and kidx represent a solveable board
Submission
At a minimum, submit the following files: TestHwpy
hwpy
Students must submit individually by the due date typically Tuesday at : pm EST to receive credit.
Grading
This homework is manually graded.
Feedback
If you have any feedback on this assignment, please leave it here.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
