ThoughtWorks Interview Process – Part 1

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.


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).

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.

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


Test Input:
5 5
1 2 N
3 3 E

Expected Output:
1 3 N
5 1 E

24 thoughts on “ThoughtWorks Interview Process – Part 1

  1. 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.

  2. 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.

    1. 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.

    1. 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.

  3. 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++) {
    private void process(Character command) {
    if (command.equals('L')) {
    } else if (command.equals('R')) {
    } else if (command.equals('M')) {
    } else {
    throw new IllegalArgumentException(
    "Speak in Mars language, please!");
    private void move() {
    if (facing == N) {
    } else if (facing == E) {
    } else if (facing == S) {
    } else if (facing == W) {
    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.setPosition(3, 3, E);

  4. 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:):)

  5. 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.

    1. 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.

      1. Alright 🙂 thanks. And do they offer good packages? Since i have got no info related to package till now.

  6. 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!

  7. 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

  8. 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

Leave a Reply to ranganathg Cancel reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s