Checkerboard King Combo Move
Description:
In traditional American checkers (also known as draughts outside the U.S.), when one of your pieces becomes a king, it gains the advantage of being able to move diagonally in any direction. This adds more possibilities with regard to capturing multiple enemy pieces in a single turn.
In this kata you are presented with an n x n
board. While your opponent has several pieces on the board, you have only one remaining piece — a king. Using the same mechanics as in American checkers, your goal is to capture the maximum number of enemy pieces in the next move with your king.
Input
Your function will receive an array of length n
comprised of strings of length n
. Each string value represents each row of the board, from top to bottom.
" "
: an unoccupied cell denoted by a space characterX
: a cell occupied by an enemy pieceK
: the location of your king piece
Output
Your function should return the maximum number of enemy pieces that can be captured in one turn.Test Example
board = [
' X',
' ',
' X X X ',
' ',
' X X X ',
' ',
' X X ',
' K '
]
king_move_combo(board) #7
Below (left) is a graphic representation of the example board
and (right) a set of moves to obtain the solution.
Technical Details
- Input will always be valid.
- Board size range:
16 >= n >= 8
- In JavaScript, prototypes have been frozen and
require
has been disabled.
If you enjoyed this kata, be sure to check out my other katas.
Similar Kata:
Stats:
Created | Dec 16, 2017 |
Published | Dec 17, 2017 |
Warriors Trained | 321 |
Total Skips | 39 |
Total Code Submissions | 490 |
Total Times Completed | 64 |
JavaScript Completions | 33 |
Python Completions | 37 |
Total Stars | 11 |
% of votes with a positive feedback rating | 100% of 26 |
Total "Very Satisfied" Votes | 26 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |