Codility

14

Codility( http://www.codility.com) is web application which helps employer to filter best programmers from average programmers. Codility Limited is based in London, UK.

Codility saves time of software talent recruiters by filtering out job candidates who cannot write correct program.

Codility administers short programming tests and checks whether solutions are rock solid.

During recruitment process employers can use Codility and choose different programming tests which can be emailed to candidates. Candidates can solve the problem on web browser and can submit the solution by clicking the submit button. Once solution is submitted Codility performs range of testing on the source code and try to evaluate which canidate solved the problem in best way. Normally you can write the soultion for interview test under 20 lines of code but if your algorithum is not robust then it will fail the Codility test. During validating the source code, Coditiy internal application will test your program with both valid and invalid data. On top of that it also measures how long your algorithum is taking to process large amount of input. Normally during test you can see the requirement for Bio O notion on the screen such as O(1), O(N) etc. The good thing about codility is that candiate can use the language they are comfortable with.

Now you must be wondering why i am writing about this company. Well during one of my job interview i was asked to do online test on Codility website, I thought that it will be multiple choice question and it will be very easy to pass the test. Once i reached home, i opened Codility website and decided to try few of their sample questions. For one of their sample question i was not able to understand the question so i skipped to the next one. Well next question i understood but i did not realized that i will be tested on speed of my algorithum. So i started writing code for sample test in Java, it was so difficult to write code on their browser because it breaks all the indentation and curly brackets; are placed on the wrong places. If codes are not indented nicely then i can’t even read my own code 🙂 . Well after finishing the solution i submitted to see my result. Guess what? I FAILED the test. The test result failed me on timing. At that stage i got so nervous, that i decided to try another sample test and i was not able to solve it within time limit( I guess sample test need to be solved within 30 min, I can’t remember exact timing). On that night i could not sleep, i felt like i am hopeless and not able to write simple line of code.

Next day i asked my friend to try Codility sample test and he failed as well, well now i was relieved 🙂 . Next day i asked one of top student of my class to try sample test and he failed in timing test as well. I was really scared that i will not get face to face interview with this company.But anyway i decided to try the actual test whose link was emailed to me. Before starting my test i opened my java IDE and clicked link to begin my test.My first question was to reverse a String, i was so happy after looking at that question and finished it quickly. But since i was scared,i started testing my code with different data. My second question was about “Nested Parentheses” where you will write a code to find if parentheses are properly nested on not. If your have brackets like this ” ( ) ” or ” ( ( ) ) ( ) ” then it means that it is properly nested but if you have bracket like this ” ( ( ) ” or ” ) ) ) ( ( ( ” then it means that its not properly nested. And i was supposed to handle String of length 200,000 characters.

It took me rougly 10 minute to plan how i am going to solve the problem and i came with following algorithum.

  1. Remove all spaces from String.
  2. Count the length of String, and find out if its odd or even number. If string is odd number then it is not properly nested.
  3. If String is even number then run a loop and remove all matching ” ( ) ” character from the string.
  4. Now check the length of String, if length is zero then String is properly nested else its not.

Once i figure out the algorithum, i started writing my code. Below is solution of my code.


class Solution
{
    public int nesting ( String S )
    {
        int result = 1;

        if(S.contains(" "))
        {
            S = S.replaceAll(" ","");
        }

        while(S.contains("()"))
        {
            S = S.replaceAll("\\(\\)", "");
        }

        if(S.length() != 0)
        {
            result = 0;
        }

        return result;

    }
}

Tips for sitting down for Codility test

  1. Only attempt test when you are completly free.
  2. Don’t type your code in Codility browser, decide which language you will be using and open your IDE before the test.
  3. IDE helps alot because you don’t have to remember whole API.
  4. Sit down for test where there is no distraction.
  5. Down try to solve the problem as soon as you get the question, think nicely and plan your algorithm on the paper first.
  6. Once you write your program,  test it will lots of invalid data. You can test your program on Codility browser.
  7. Practice sample test before sitting down for actual test.
  8. Don’t use nested for loops or nested branch statements in you solution(try to avoid them).
  9. RELAX.

My Final Thoughts

I prefer to be tested by humans rather than machines because i can explain to humans what i am thinking and how i am going to solve the problem. If i miss one comma in my program then human can understand it but if i miss one comma in program then machine can’t understand it and I may fail because of comma( if you are really scared of comma then learn Ruby language 🙂 ).

But on the positive side Codility can definitely save lots of time for employers  Company can not interview all the candidates who send them resume and I dont believe in resume because no one writes real thing on their resume. Every one says that they are punctual on their resume but on the very first day of their job they are late. In those cases Codilty can help employers to filter few candidates  for face to face interview. If i will ever own a software company then i may use software like Codility to help me with recruitment process or i may ask all my candidates to draw UML diagram for certain problem domain.

BTW i got 190/200 in my actual test.