Testing programmers skills

BlackSad

New member
Joined
Aug 30, 2011
Messages
2
Programming Experience
3-5
Hi,
I was recently applying for a job and I got a pre-interview test on Codility.com -- they give you a program to write according to spec. It seemed cool at the first sight, but later the employer told me that I done poorly, because the system has found errors in my code, while there were no errors when I was writing a solution. Has anybody solved this test and is there a way I can find out what errors I made or is this just the employer does not want to hire me because of something unrelated?

Thanks for help.

BlackSad
 
Why dont you ask the employer for some feedback?
What was the question(s) and your answer to them?
 
Just a question for anyone else seeking a job. Is Codility a standard in screening programmers in this job market? Do their tests hold any water?
 
Why dont you ask the employer for some feedback?
What was the question(s) and your answer to them?

Hi,

The task was to calculate how many numbers between a and b are divisible by k.

Here is my answer:

Private Function count_div(a As Integer, b As Integer, k As Integer) As Integer
Dim result
result = 0
Dim i
For i = a to b
If (i mod k) = 0 Then
result += 1
End If
Next
count_div = result
End Function

Isn't it correct?
 
I don't know for sure where you're falling down.

However I notice that you don't specify what result and i are going to be (as integer) when you dimension them.

You might also lose out on efficiency marks, since checking every number is a waste of time. The answer will be approximately (b-a)/k, with a bit of fiddling to make sure you handle the top and bottom values correctly.
 
...You might also lose out on efficiency marks, since checking every number is a waste of time. The answer will be approximately (b-a)/k, with a bit of fiddling to make sure you handle the top and bottom values correctly.
Simple example:
how many numbers between 3 and 6 are divisible by 3.
(6-3)/3 = 1
Is that correct?
No, because I'm sure the answer is 2 numbers -> 3 and 6. :)
 
Simple example:
how many numbers between 3 and 6 are divisible by 3.
(6-3)/3 = 1
Is that correct?
No, because I'm sure the answer is 2 numbers -> 3 and 6. :)

That's why I said approximately. I don't generally approve of doing people's homework for them, so the particulars of the code needed to "handle the top and bottom values correctly" remain for them to solve.. :)
However I can say that I've written a script in python which solves this (correctly) using the division model I refer to. Since it doesn't involve looping, it is just as quick finding how many multiples of 3 are between 3 and 30000000000 as between 3 and 6. The algorithm originally submitted would need to run through a loop ten billion times to answer such a problem. That means that the original algorithm is of efficiency order n while mine is efficiency order 1.
 
That's why I said approximately. I don't generally approve of doing people's homework for them, so the particulars of the code needed to "handle the top and bottom values correctly" remain for them to solve.. :)
However I can say that I've written a script in python which solves this (correctly) using the division model I refer to. Since it doesn't involve looping, it is just as quick finding how many multiples of 3 are between 3 and 30000000000 as between 3 and 6. The algorithm originally submitted would need to run through a loop ten billion times to answer such a problem. That means that the original algorithm is of efficiency order n while mine is efficiency order 1.
Well done, I suppose your solution solves the problem correctly for any range of integers and any integer divisor.
Imagine this is a brand new task for you. How long will it take you to finish it correctly and how long and complex the final scrypt will be?
He had 30 minutes to understand the task description, to implement, test the algorithm and submit the solution on their web site. Just to remind you the employer told him that he did poorly, because his algorithm is of efficiency order N not 1.
 
Yes my algorithm works for any set of integers including zero and negatives. It is true that writing my own script did take me longer than half an hour, though that was largely because I (a) hadn't used python before and (b) had to build in the inputs, input data checks, etc in addition to the actual algorithm.
But what's your point? All I'm trying to do is show ways in which that code might have been improved, in a way that hopefully everyone benefits.
 
Just a question for anyone else seeking a job. Is Codility a standard in screening programmers in this job market? Do their tests hold any water?

Codility is just one of many online testing tools for programmers...if you browse around you'll find other similar useful webs like testdome or interviewstreet and other. Codility is pretty popular since it exists now for cca 5 years, but it doesn't mean that it is best tool or that it's standard in this category. Which testing tool will they use to measure your skills depends completely on employers needs, but my opinion is that good test should cover various programming skills, algorithmic thinking and problem solving with multiple answer/choice questions as well as with live coding questions to get complete idea of candidate's skills.
 
Back
Top