
Checkers Capture

Imagine a n-by-n chessboard, where your single checker currently stands at position (x, y) and there is pieces - a list that contains the positions of the opponent’s pawns.
Your checker may capture a piece only one step in the four diagonal directions assuming that the square behind the opponent piece in that diagonal direction is vacant. Your checker can then capture that piece by jumping over it into the vacant square, immediately removing that captured piece from the board. The chain of captures continues from the new square, potentially capturing all the pieces in one swoop.
Your function should return the maximum number of pieces that your checker could potentially capture in a single move.
Input: Three arguments: size (number), coordinates (array of two integers (number)) and a sequence of opponent's pieces (array of coordinates).
Output: Integer (number).
Examples:
assert.strictEqual( maxCheckersCapture( 5, [0, 2], [ [1, 1], [3, 1], [1, 3], ] ), 2 ); assert.strictEqual( maxCheckersCapture( 7, [0, 0], [ [1, 1], [1, 3], [3, 3], [2, 4], [1, 5], ] ), 3 ); assert.strictEqual( maxCheckersCapture( 8, [5, 3], [ [6, 2], [2, 4], [2, 2], [0, 4], [5, 5], [1, 5], [3, 7], [6, 4], [5, 7], [0, 6], [0, 2], [1, 7], [2, 6], [6, 0], [6, 6], [3, 5], ] ), 1 );
The mission was taken from Python CCPS 109. It is taught for Ryerson Chang School of Continuing Education by Ilkka Kokkarinen