• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 7. Two -dimensional arrays

Difficulty level:

Task«Chessboard»

You are developing a module for analysis of chess parties. You need to realize an algorithm that determines whether the king of the player is under the shah after each move in the party. The chessboard is presented in the form of a two -dimensional massive 8x8, where each cell can contain information about the chess figure or be empty.

Input format

a two-dimensional array (list of lists) of 8x8 size, representing a chessboard. Each element of the array is a line indicating the figure on the cage: rn
"k" is the white king
rn "q"-white queen
rn
rn
"> ">"> ">"> ">"> ">"> ">"> ">" Elephant rn
"n"-white horse
rn
" p "-a white pawn
rn
"k" is black King rn
"q"-black queen
rn
" r "-black boat
rn
"b" is black-black is black Elephant
rn
"n" is a black horse
rn
" p "-black pawn
rn
">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> -empty cage
rn
first the board is supplied, and then the color of the king (w "-" w "-white," b "-" b "-" b "-b"-"b"-" Black)

Output format

The program must derive "true" if the king is under the foot, and "false" if the king is not under the foot

Example

Input

.. k .....
........
........
........
........
........
..r .....
k .......
w

Output

true

Hint

There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!