You need to sign in or sign up before continuing.×
Retired
Is This Piece Under Threat? (retired)
Description:
The task:
There are some pieces on the chessboard, but only two are used in this Kata: the chess knight (K
) and any other piece (let's say k
).
Your task is to implement a function that returns True
if the conditional piece(k
) is threatened by the knight(K
), and return False
if the conditional piece(k
) is not threatened by the knight(K
).
Some notes:
- ♘ Chess knight
K
- � Conditional chess piece
k
The function parameter is a chessboard with different arrangements of the above two pieces.
Chessboard example:
- 1 - black cell
- 0 - white cell
chess_board = [
[0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0]]
Chessboard example with different arrangements of two pieces:
chess_board = [
[0, 1, 0, 'k', 0, 1, 0, 1],
[1, 0, 1, 0, 'K', 0, 1,0],
[0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0]]
If you suddenly forgot how a chess knight can walk, then here's a hint for you:

Algorithms
Puzzles
Fundamentals
Similar Kata:
Stats:
Created | Mar 29, 2022 |
Warriors Trained | 28 |
Total Skips | 1 |
Total Code Submissions | 207 |
Total Times Completed | 24 |
Python Completions | 24 |
Total Stars | 2 |
% of votes with a positive feedback rating | 50% of 12 |
Total "Very Satisfied" Votes | 3 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 13 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |