info@meritcampus.com    +91-85006-22255
...

In chess, assuming that the columns are numbered A to H and the rows are numbered 1 to 8. Write a program to find all the possible positions which a black horse can move without getting killed by white minister and white horse. Assume that there is nothing else on the chess board apart from these three.
NOTE: The list returned should be first sorted by columns and then by rows, so A4 comes before B1 and C7 comes before D5 etc.,

Input (Black Horse Position, White Minister Position, White Horse Position) Output (Sorted List of Positions)
Black Horse = D4, White Minister = A3, White Horse = B8 [B5, C2, E2, E6, F5]
Black Horse = G4, White Minister = D4, White Horse = D6 [H2, H6]
Black Horse = D4, White Minister = F6, White Horse = E3 [B3, B5, E2]
Black Horse = E2, White Minister = C4, White Horse = G4 [G1, G3]

``` class FindBlackHorsePositionsWithWhiteMinisterAndHorse {    public static void main(String s[])    {        ChessPosition blackHorse = new ChessPosition('D', 4);        ChessPosition whiteMinister = new ChessPosition('A', 3);        ChessPosition whiteHorse = new ChessPosition('B', 8);        System.out.println("The positions which the black horse can move to with out getting killed : " + getBlackHorsePositions(blackHorse, whiteMinister, whiteHorse));    } public static List<ChessPosition> getBlackHorsePositions(ChessPosition blackHorse, ChessPosition whiteMinister, ChessPosition whiteHorse) { //Write code here to get the positions in which the black horse can move with out getting killed by white minister and white horse } } class ChessPosition { char column; int row; public ChessPosition(char column, int row) { this.column = column; this.row = row; } @Override public String toString() { return column + "" + row; } } ```
0
Wrong
Score more than 2 points