CDAC-ACTS Interview Question Computer Scientists

  • cdac-acts-interview-questions
    0
    of 0 votes
    6
    Answers

    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

    - dev on June 17, 2012 in India Report Duplicate | Flag
    CDAC-ACTS Computer Scientist Java

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.

- Anonymous on June 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

tl;dr

- Anonymous on June 19, 2012 | Flag
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.

- Get a life on June 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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.

- dev on June 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

well this question is common pattern for C-DAC . They have

- amit on March 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Well its true !!! . this question is common pattern for C-DAC. code is written in unix OS on emac or vi editor and then its run on parishak machine grading tool where i/ps are passed to your code and o/p is given in Y means correct and X means wrong per test i/p.
Questions on puzzles ,games specifically matrix related problems are asked.

- amit on March 03, 2014 | Flag Reply


Add a Comment
Name:

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

Books

is a comprehensive book walking you through getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More