The tool is awesome, but I wouldn't rely too much on the instruction bounds. For example, the greatest sums exercise ( http://people.csail.mit.edu/pgbovine/python/question.html?op... ) can be solved in six "steps" for all input lengths, while it's certainly no O(1) business. def maxPairSum(data): return sum(sorted(data)[-2:]) # one "step"
Actually, both your solution and theirs are not O(1). Theirs is n^2, while yours is n lg n due to the use of a sort function. The best way to do this would simply be to find the largest element, ignore that element and find the largest element again, which is O(n).
Since the whole point of the exercise is "optimizing" maxPairSum so that it runs in 20 "steps" or less, I guess this slower solution is still more "optimized" - which was my whole point, after all. :)
(Please note 6 steps is the bare minimum - one for the function definition, one for preparing input, one for calling the function, one for calling the function, one for assigning function arguments, one for the actual function and one for returning from the function. You can't go shorter than this.)