## CDAC-ACTS Interview Question Computer Scientists

• 0

i was asked the following question and they need java solution for it.

Checkers is an ancient board game played by two players, traditionally called 'Black' and 'White'. It is played by turns on an 8x8 board, which has alternating black and white squares. All the pieces are placed on black squares only and move in a diagonal fashion, i.e., a piece cannot move vertically or horizontally, but only diagonally.
When it is a player's turn, he can either make a move or a sequence of jumps. A jump is defined as a diagonal move over exactly one piece of the opposing colour. The piece that has been jumped over is said to be captured, i.e., it is removed from the board. The players try to capture as many of the opponent's pieces as possible and the game ends when all the pieces of any one player are captured.

Checkers rule states that the white piece (A) has a choice of moving to his left, or jumping over the black piece. Since the intent of the game is to capture as many of the opponent's pieces as possible, White should choose 'A' to jump over the black piece. After jumping, 'A' reaches a square from which he can jump further, either left or right. The jump to the left is better because it allows White to make one more jump, unlike the jump to the right, which leads to no more jumps. The white piece (, in the figure, can only move and not jump. Thus, according to the figure, White can jump thrice in one turn, using 'A' or alternatively can move once using 'B'. Obviously, the better choice is jumping with A.
You have to write a program which, given a board configuration, calculates the maximum number of jumps possible in one turn, by any White piece. Given the board above, the program would output '3'.
Notes:
It is illegal to jump over a piece of your own colour.
A player's turn is complete when he makes either a move or a sequence of jumps.
A jump can land only on an empty square.
Input specification:
The input will consist of eight (8) lines of eight (8) characters each. The characters will be one of the set {B, W, ~, #}.
� B => Black piece
� W => White piece
� ~ => An empty black square
� # => White square. Note that a piece can never land on a white square
Output specification:
Your program has to output the maximum number of jumps that can be made by any of the white pieces. If white cannot make any jump at all, then your program must print the integer '0' (zero)

Sample Input and Output:

Input:
#B#~#B#~
B#B#B#B#
#~#~#~#~
~#B#~#~#
#~#W#~#~
~#~#~#~#
#W#W#W#~
W#W#W#W#

Output:
4

Input:
~#~#~#~#
#B#B#B#B
~#~#~#~#
#B#B#~#~
~#~#~#~#
#~#B#~#~
~#W#W#W#
#W#W#W#W

Output:
5

Country: India
Interview Type: Written Test

Comment hidden because of low score. Click to expand.
0
of 0 vote

it is a very hard problem.
No one can solve it.

Comment hidden because of low score. Click to expand.
0

tl;dr

Comment hidden because of low score. Click to expand.
0
of 0 vote

No one will ask such question in a F2F or telephonic interview.The formatting itself shows you have copy pasted the question. You just want a working java solution to copy paste the solution in some online screening interview.

Comment hidden because of low score. Click to expand.
0

this question was not a telephonic, it was a written test.
Where i had to make an algorithm, after checking algo, they told me to write the code on machine.
One more, no such company asked question like this.

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book walking you through every aspect of getting a job at a top tech company, while focuses on software engineering interviews.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.