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:

example image
Algorithms
Puzzles
Fundamentals

Stats:

CreatedMar 29, 2022
Warriors Trained28
Total Skips1
Total Code Submissions207
Total Times Completed24
Python Completions24
Total Stars2
% of votes with a positive feedback rating50% of 12
Total "Very Satisfied" Votes3
Total "Somewhat Satisfied" Votes6
Total "Not Satisfied" Votes3
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • JustinBabyCoder Avatar
Ad