6 kyu
Pawn Promotion
257 of 272Eyad Hantouli
Description:
Welcome To Pawn Promotion Kata.
In this kata you will write a program that studies a chess board that contains only two pieces (pawn) and (king).
The pawn is always in the last row
as it will now turn into one of the four pieces
[queen , rook , bishop , knight]
in a process called {pawn promotion}.
Your task is to locate the king and the pawn and choose the appropriate piece to promote it and put the king in check.
The letter P represents the pawn
The letter K represents the king
Examples:
input:
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
['P', ' ', ' ', 'K', ' ', ' ', ' ', ' '],
output:
['queen', 'rook']
input:
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', 'K', ' '],
[' ', ' ', ' ', ' ', 'P', ' ', ' ', ' '],
output:
['knight']
input:
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', 'K', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', 'P', ' ', ' ', ' ', ' ', ' '],
output:
[]
Q&A:
Q:- Why was the order of the pieces in the first example as ['queen', 'rook']
and not the other way around ?
A:- In the event that there is more than one option that achieves check,
return the order of the pieces as follows [queen, rook, bishop, knight]
special cases:
If there is no piece that can make check immediately upon upgrade, return [].
If there is no pawn on the board, return [].
If there is no king on the board, return [].
Fundamentals
Similar Kata:
Stats:
Created | Apr 24, 2022 |
Published | Apr 24, 2022 |
Warriors Trained | 652 |
Total Skips | 8 |
Total Code Submissions | 1649 |
Total Times Completed | 272 |
Python Completions | 257 |
COBOL Completions | 5 |
C Completions | 20 |
Total Stars | 28 |
% of votes with a positive feedback rating | 93% of 76 |
Total "Very Satisfied" Votes | 67 |
Total "Somewhat Satisfied" Votes | 7 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 11 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |