RSS

ThoughtWorks Interview Process – Part 1

16 Nov

I have applied to ThoughtWorks (TW) from their job portal. The process starts with a Coding Assignment (will explain details in a while). If they are satisfied with your solution, they would invite you onsite. In the office you have a written test, one code-pairing round, then an interview panel discussion, then a written test and if things go fine you meet the General Manager.After all these things you will be asked to take some predictive index survey. Thats it!! 🙂

Let me explain things a bit in detail.

1. Coding Assignment:

After the resume screening, the HR will get in touch with and mail you the assignment problem and gives you enough time to send them the solution.

You will be sent two coding problems : One is the famous “Mars Rover” Problem and the other is “Sales Taxes” Problem. You can solve any one of the problems. I choose to solve the Mars Rover problem since it looked a bit interesting to me. [I am not pretty sure if solving both the problems has any advantage!].

Since I was kind of very occupied with my work, I worked over the Mars Rover problem on a friday night and mailed them the solution.

Things to consider when you are working on the assignment:

1. The problems given for the assignment can be solved using procedural programming in just 1 or 2 hours may be. But TW wants you to give more focus on the Design aspect.

2. Have a proper packaging structure, Exception handling, Test cases, boundary conditions. Importantly a proper documentation of the code. This should be something like you can ship it [I made this up :P]

PS: Everything I said here is from my perspective.

PROBLEM ONE: MARS ROVERS 

A squad of robotic rovers are to be landed by NASA on a plateau on Mars.
This plateau, which is curiously rectangular, must be navigated by the
rovers so that their on-board cameras can get a complete view of the
surrounding terrain to send back to Earth.

A rover’s position and location is represented by a combination of x and y
co-ordinates and a letter representing one of the four cardinal compass
points. The plateau is divided up into a grid to simplify navigation. An
example position might be 0, 0, N, which means the rover is in the bottom
left corner and facing North.

In order to control a rover, NASA sends a simple string of letters. The
possible letters are ‘L’, ‘R’ and ‘M’. ‘L’ and ‘R’ makes the rover spin 90
degrees left or right respectively, without moving from its current spot.
‘M’ means move forward one grid point, and maintain the same heading.

Assume that the square directly North from (x, y) is (x, y+1).

INPUT:
The first line of input is the upper-right coordinates of the plateau, the
lower-left coordinates are assumed to be 0,0.

The rest of the input is information pertaining to the rovers that have
been deployed. Each rover has two lines of input. The first line gives the
rover’s position, and the second line is a series of instructions telling
the rover how to explore the plateau.

The position is made up of two integers and a letter separated by spaces,
corresponding to the x and y co-ordinates and the rover’s orientation.

Each rover will be finished sequentially, which means that the second rover
won’t start to move until the first one has finished moving.

OUTPUT
The output for each rover should be its final co-ordinates and heading.

INPUT AND OUTPUT

Test Input:
5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM

Expected Output:
1 3 N
5 1 E

Advertisements
 
24 Comments

Posted by on November 16, 2010 in ThoughtWorks

 

Tags: , , , ,

24 responses to “ThoughtWorks Interview Process – Part 1

  1. yogu

    June 16, 2012 at 5:32 pm

    can u mail me the program which u hav sent to them..

     
  2. ranganathg

    June 22, 2012 at 11:22 am

    Hey Yogu,

    I cant do that. A quick search on the net would show you that for the Mars Rover problem you can use State Pattern.

    Just to let you know I didn’t follow this approach, since there is no use copying the code and getting shortlisted because you would be given an extension to this problem during your onsite. So unless you have a grip on the problem requirements, it wouldn’t be easy.

    So what I want to say is try it out yourself – Its fairly easy and trivial. And keep in mind some of the things I have mentioned in the post.

    Good luck.

     
  3. ajay

    July 15, 2012 at 1:03 pm

    sir,
    i’m doing final year B.Tech ..
    TW coming for recruitment by next week .I had prepared for logical assetment…. i will crack that!!!!!
    For mars rover problem i have developed a code using C.. i have used switch case statements…but TW will concentrate only on oop designs…where they won’t accept my code i think…
    Can you please help me..i will mail my code to you….
    please do the needful sir.

     
    • ranganathg

      July 16, 2012 at 1:42 pm

      Just because you didnt use OOP design wouldnt result in not accepting the code. If you have proper abstractions and your code is modular, that should also be good. Since you are a final year student, they might not be expecting a solid design. And since its C, you might not be able to use few rich OOP constructs available in OO languages like Java, C#.
      Good luck and all the best for your placements.

       
    • Navjot Singh

      January 28, 2016 at 12:54 pm

      C is procedural,

       
  4. ajay

    July 17, 2012 at 2:49 pm

    Thank you sir,,
    but i need your suggestions for making that code more modular,shippable..

     
  5. ranganathg

    July 19, 2012 at 6:17 pm

    Sure, probably upload it in github and post the link here. fine?

     
    • ranganathg

      July 22, 2012 at 6:33 pm

      there is no code in the depo which i can see

       
  6. ajay

    July 23, 2012 at 5:32 pm

     
    • ranganathg

      July 23, 2012 at 5:59 pm

      1. Avoid using global variables
      2. Too many switch statements
      3. What if the input is more than 50 chars? What if there are invalid chars?
      4. Use proper naming convention for the variables.
      5. If you are asked to add some extensions – you need to modify an already tested code.
      6. How about the cases where Robot moves outside of the box?

      See, the main thing in the question is the modularity not just the answer. Since this is a very simple question getting the answer is not the important part. Modularity and extensibility is what is primarily import. Since you gave a C code I couldnt give you comments on your design. Had it been Java, I would have added more comments – packaging, exception handling, inheritance etc etc.

       
  7. ajay

    July 24, 2012 at 4:45 pm

    package marsrover;
    public class Rover {
    public static final Integer N = 1;
    public static final Integer E = 2;
    public static final Integer S = 3;
    public static final Integer W = 4;
    Integer x = 0;
    Integer y = 0;
    Integer facing = N;
    public Rover() {
    }
    public void setPosition(Integer x, Integer y, Integer facing) {
    this.x = x;
    this.y = y;
    this.facing = facing;
    }
    public void printPosition() {
    char dir = ‘N’;
    if (facing == 1) {
    dir = ‘N’;
    } else if (facing == 2) {
    dir = ‘E’;
    } else if (facing == 3) {
    dir = ‘S’;
    } else if (facing == 4) {
    dir = ‘W’;
    }
    System.out.println(x + ” ” + y + ” ” + dir);
    }
    public void process(String commands) {
    for (int idx = 0; idx < commands.length(); idx++) {
    process(commands.charAt(idx));
    }
    }
    private void process(Character command) {
    if (command.equals('L')) {
    turnLeft();
    } else if (command.equals('R')) {
    turnRight();
    } else if (command.equals('M')) {
    move();
    } else {
    throw new IllegalArgumentException(
    "Speak in Mars language, please!");
    }
    }
    private void move() {
    if (facing == N) {
    this.y++;
    } else if (facing == E) {
    this.x++;
    } else if (facing == S) {
    this.y–;
    } else if (facing == W) {
    this.x–;
    }
    }
    private void turnLeft() {
    facing = (facing – 1) W ? N : facing + 1;
    }
    public static void main(String args[]) {
    Rover rover = new Rover();
    rover.setPosition(1, 2, N);
    rover.process(“LMLMLMLMM”);
    rover.printPosition();
    rover.setPosition(3, 3, E);
    rover.process(“MMRMMRMRRM”);
    rover.printPosition();
    }
    }

     
  8. ajay

    July 25, 2012 at 4:57 pm

    i have got correct answer…i have gave input in progarm itself… but need to get input from the user….please tell me how to code that….whether to use buffered reader inp…. or some other….

    but memory consumption must be less….
    reply me soon sir…
    27 th is placements…

    thank you:):)

     
  9. ranganathg

    July 26, 2012 at 8:57 am

    use BufferReader or Scanner, that shouldnt be a problem.
    Good luck

     
  10. Nupur

    September 7, 2012 at 4:24 am

    Hi

    I have got an interview call from thoughtworks. I have chosen sales tax problem. Do you have any idea what extension they can ask for, related to this problem. What is the level of their technical rounds. Will it be the same for everyone or it is different for the people having less experience. I am 2 years experienced.

     
    • ranganathg

      September 7, 2012 at 5:40 am

      FYI, I was interviewed with them when I had 2 years of experience. The extension is fairly simple, doable very easily. I don’t want to spoil your fun :). Technical rounds are algorithmic discussions, starting point is your resume. If you are thorough with your basic thats enough. Since I had some graph related projects on my resume, I was asked graph algorithms. But that wouldn’t be the same for everyone.
      One thing is be confident. Be open.
      Good luck.

       
  11. Nitin Piparava

    August 11, 2013 at 6:11 am

    Do anyone have experience with tictactoe game? Please let me know which type of extension question can arrive

     
  12. ranganathg

    September 9, 2013 at 3:21 pm

    Hey Nitin,

    I am not aware of the tic-tac-toe question that is asked by TW. Send across that question to me, will try to think of an extension myself. Usually the extensions are not that difficult, they would be more around adding an extra condition to the question and see how minimal code changes you make to your code to make things work (extensibility of your code).

    Good luck!

     
  13. Manishankar Layak

    June 27, 2014 at 8:02 pm

    How does one prepare for the immaturity in the interview?

    http://lovethoughtworks.blogspot.com/2014/06/a-hilarious-review-on-thoughtworks.html

     
  14. asis dey

    August 13, 2014 at 3:42 pm

    Hi, I got a call from TW and they have given me the ” Merchant’s Guide To The Galaxy” problem.
    I have written the draft code. PLease help me for the design and what are the points i have to follow for the code.. Please help. Thanks

     
  15. ranganathg

    August 21, 2014 at 2:17 pm

    You can send me the question and code. I can quickly do a review and provide any comments. mail me at rangag[at]outlook[dot]com and drop a message here

     
  16. prasanna aarthi

    October 17, 2014 at 8:46 am

    Sir, I have sent you the question and my code.Please help me with the review.

     

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: