Question: There is a n * n square board, theres a new kind of game which is played on this board. there are pieces on the

There is a n * n square board, theres a new kind of game which is played on this board. there are pieces on the board which can only move horizontal and vertical any number of squares until it encounters an opponent piece, when it does so, it replaces the opponent piece at that position and the turn alternates. The input will contain a n * n matrix with 1,2 and 0 in the cells. 1 denotes your pieces, 2 denotes opponent pieces, and 0 denotes free space. One of your pieces has fallen from the board and neither you nor your opponent remember its original position, so you collectively decide that you can place it anywhere you want to, so its upto you to place it at a position where you can maximize the number of opponent pieces you can cut. Output the x and y coordinates of such position. If multiple positions exists, output anyone.

Program in Java or Python.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!