Codility - Automated tests of programming skills
codility.com
codility.com
I have no idea where you saw this being implied. The software highlights syntax and lets you check your code as many times as desired, as well as giving hints if your result isn't correct and providing compiler output. Nothing stops you from googling something. It's not like the software will destroy your file and egg your house because your algorithm is o(n2) instead of o(n); that's up to whoever is evaluating the results.
The fact that it has a polish and chinese version should also give you a little hint about the intended audience.
That said, as soon as the test popped up, I opened my eclipse, wrote the code, cut & pasted .. viola! (in python btw)
It would be nice if the boundary conditions were better specified (people seem to have been bitten by overflowing integers). This could be inferred if you told people that you're using a 32-bit machine (the sum of elements is at most SIZE_MAX * INT_MAX; if int and size_t are 32-bit, SIZE_MAX * INT_MAX < INT64_MAX.)
I was also somewhat surprised to see that my code compiles without #include <stdint.h>. I'm not sure this is correct (it could be solved by putting the code written by the candidate before the test code).
Finally, I assume you have proper sandboxing set up?
#include --- good catch! We are not very strict about missing includes, but this is definitely not something we want to penalize.
Sandboxing -- absolutely! :-)
I got 94 using C in 12min (didn't check for overflows of large numbers, silly haskell making me used to Integers).
I'd give people access to their language's output facility for playing around to the solution, but that is a minor nitpick. (And I suppose I could open an irb instance on my machine for exploration and then give you code when I'm good and ready.)
My Ruby solution, in case we've got anybody who is struggling: http://pastie.org/771438 This would be my first cut if you asked me to whiteboard this.
The site's very slick. My only feedback is the histogram on the results page could be more prominent - it's cool, useful information but I ended up inspecting the html elements to work out what it was.
Also the results page seemed to keep refreshing for me while waiting for results (Safari 3). Surely that should've been AJAX'd?
def equi ( A ):
right = sum(A)
left = 0
for i,x in enumerate(A):
right -= x
if right == left:
return i
left += x
return -1
What's interesting is that all the versions I've seen so far are pretty much identical apart from very minor things. This would seem to me to be obviously the correct way to do it but I'm interested if it's just a way. Did anyone solve this in a different way of equal or greater elegance? for i in xrange(len(A)):
if right[i] == left[i]:
return i
The final loop here is slightly tighter, so as long as your parallelism didn't add big overheads, this will be faster.Original: http://pastebin.com/m6e742f56 Parallelised: http://pastebin.com/m32a60b1
In face-to-face interviews you'd probably follow up by adding constraints: "your algorithm uses O(n) space in addition to the input, can you do it in constant space?". It would be cool if Codility supported that kind of workflow - following up the submitted solution with refinements on the original question. (Relatedly - do you support the workflow where you get a second try if you didn't get 100, maybe because the evalution revealed a constraint that wasn't clearly stated in the problem outline?)
Edit: just noticed that you'll have to wait a few days to get an embedded release that has syntax highlighting ( http://groups.google.com/group/bespin/browse_thread/thread/0... )
http://twitpic.com/x6wkq and even the code matches line by line I guess - http://twitpic.com/x6wnp
> Hmm so Codility's editor is copy of the one SPOJ uses
Please don't flame. Codility has not copied it from anybody, its EditArea-based interface is in place since 2008.
Hmm so Codility' and SPOJ use a similar editor, so which one do they both use? Can I too get it :)
Thanks for pointing out. /me looks into EditArea
http://www.cdolivet.com/index.php?page=editArea
very nice project on LPGL license.
best Marcin Codility
You might want to lock down functions like glob() and readfile() in PHP -- they effectively give the coder read access to your file system.
It isn't that difficult to solve, but I like the idea.
Does that ever seem like a good idea? The description suggests it may be a long list. That should give you a hint that you don't need to do this to solve the problem.
The worst case of the best algorithm is to iterate twice - firstly as above, and then again in the opposite direction, comparing values from the first iteration.
Unfortunately, revealing whether my assumption proved correct would give away how they assess the solution to this demo problem, which some might view as a spoiler.
EDIT: since people are posting actual solutions, I suppose mere analysis of the testing methodology is okay. My assumption was correct.
I also like the way you tell me what you scored on and what my result was.
I wonder if you should relax the condition that you can submit only once.
I gather TopCoder offers something similar. What's your strategy to compete with them?
PS: got 94 using C++ in 16 min b/c I didn't check overflow of large numbers. Good thing you check for that.
It's also taking a metric fuckton of time to evaluate my solution. Which apparently fails. For reasons I can't debug because I can't see the test data.
Any company that relies on code snippets, incomplete problem statements and undefined test data to judge coders will get what they deserve.
it wasn't obvious to me what to do on first read, but when i paid a little more attention, everything was there (including edge cases, as far as i could see). in particular, they gave a formal numerical expression that was unambiguous (and which didn't seem to contradict the text).
EDIT: It appears I can customize my test dataset, and I didn't see it. Silly me.
Edit: And won't this be a problem if interviewees can access the internet? The interviewers will have to make sure they can check the browsing history of the computer being used!
The test window's layout is fubar if you use a small window size. I was using 800x600 and the language selection buttons were hidden behind the source code text box. Something (couldn't tell what) overlapped the first two lines of the instructions.
Firefox 3.5.7/Ubuntu Linux 4.10, FWIW.
Maybe you should time the programs, instead of the programmers.
As for comfy conditions on the job - I would hope that default conditions are comfy. When interviewing I'm more interested in how people will perform day-to-day rather than in rare situations. Most programming jobs don't really require employees to be "cool under pressure."
Other than that, good job on the execution so far. Reminds me a lot of TopCoder, just applied to a specific niche in a good way. I would even consider using this or recommending it to colleagues for hiring.
Consider making the clock like on http://www.sudokuslam.com/ - with an icon right next to it to show or hide it.
eg. if the programmer goes off and writes a multithreaded solution, they might only realise too late that pthread isn't included. Admittedly they should have checked first using verify, but you never know with interview pressure.
That said: Jesus I must still suck, or maybe Math simply isn't my strong suite.
BTW 10-20% of the population is like me.
I readily concede that coding ability isn't the only thing a dev needs, but it is absolutely required for most jobs.
I took a demo quiz and it worked fine. Great idea for a product.
However I think I'm too competent for the test because I was able to run something I probably shouldn't have been able too.
I've already sent it around at the company I work for. I'm hoping we can put it to use.
one thing i missed, though, was the ability to write and run my own tests. perhaps a "scratchpad" that evaluates code and returns a result would be a nice addition?
My bottom left corner is empty. Except when I click "verify" it shows message whether the tests passed or failed.
But I don't see the tests themselves, nor did I notice a way of writing my own. I've tried it in Firefox, IE 8 and latest dev Chrome.
So, is it possible to write my own tests when I'm taking the test, or only when I'm creating a new one?
Anyway, I like it a lot. It sure beats writing tests in front of a blackboard.
i can see there are several reasons why this is useful to the evaluator, and i can also see that you're getting close to saturating the user with instructions, but in a perfect world it would be good to have "full disclosure" (i guess you do, in that anyone can run the example....)