Python solutions to exercises and tests at http://codility.com/
Python solutions to the training exercises and tests at http://codility.com/
https://codility.com/programmers/lessons/
The test cases follow a predictable methodology :
You are safe to assume they won't test, mark you down for, failing to guard against the explicit assumptions described.
The "Open reading material", at the top of each lesson, is worth reading before attempting the exercises as they are short and focus exactly on what you'll need to solve the following puzzles.
During the actual interview testing/exam:
The python in
operator is a list loop and could contribute an O(N) all on it's own. ie:
foo in bar
is cheap if bar is a dictionary but potentially expensive if bar is a list.foo in bar.keys()
is a nested loop—sequentially visiting every item in the list of keys.Coming up with reasonable test cases, and determining the correct answers, is half the puzzle!
O factors are no longer provided in the descriptions, but still useful to understand and keep in mind...
Understanding the O factors reveals the nature of the optimal solution:
Codility does update the python version occasionally, and I always mirror the current version. So puzzles solved in 2018 used Python 3.7.13. In 2023 we are on 3.8.10 or 3.10.x. It's not really relevant, because all the puzzles are intended for solving in a lot of different languages and tend to only use integers and simple for loops; none of them rely on specific language features, although sometimes you may encounter quirks which impact the performance.
This next complaint appears to be fixed now, as Codility rewrote the description:
If there seems to be a lack of clarity in a puzzle regarding the correct response to error conditions: look, read, and look again because, after seeing the solution, that apparent lack will become a (debatably) reasonable assumption implied in the specs. For example in "MissingInteger" (Lesson 4):
Prime and Factors of numbers : Find factors of numbers, and primes.
Euclidean Algorithm : The greatest common divisor of two positive integers