Answered step by step
Verified Expert Solution
Question
1 Approved Answer
p _ idxs - a set of tuples representing pawn locations k - idx - a tuple representing the starting position of a knight Return
pidxs a set of tuples representing pawn locations
idx a tuple representing the starting position of a knight
Return a boolean denoting whether the passed in pidxs and kidx represent a solveable board
#
#
#
#
#Row : dots
idx# Initial knight index
# Set pawn indices
This board is solveable. Our knight can capture all pawns with consecutive moves:
However, the following board is not solveable:
#
# Row : dots
#
#
#
#
#
#
#Row : dots
idx#Initial knight index
# Set 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.
Implment validmoveskidx
validmoveskidx returns a set of tuples representing all valid moves for a knight at idx.
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started