In chess, fork means to target two pieces with just one piece, and one of the best pieces for forking is the knight.
In this challenge, you will be given three coordinates in a
to h
and 1
to 8
(like a8
or e7
) format. The first and second coordinates are for two other random pieces, and the third is the knight's coordinate. You must return or output the coordinate where the knight can move to create a fork, attacking both pieces. An example is this:
Here, the first and second inputs will be d6
and f6
and the third (knight) will be g3
. You must return e4
, where the knight can attack both rooks.
Testcases
Input: d6,f6,g3 | Output:e4
Input: d4,d6,e7 | Output:f5
Input: c3,f2,b2 | Output:d1
Notes
- You may assume it is possible to find a fork with the given input.
This is code-golf so the shortest code wins!