Best submissions - why execution time?

Dears, why you order the best submissions in the practical tasks descending on the execution time? One can see crazy nested loops instead of ready-to-use array methods.

Hi Mladen, the best submissions are actually displayed in ascending order on execution time (the fastest submissions are displayed first). The idea is to see the most optimized solutions first. If you are building such software what will be the criteria you will choose and how will you actually implement it?

Greetings,
Viktor

Thanks for the reply. I thought one should try to use whatever is available out of the box and not to reinvent the wheel. Maybe for each task we could put the nonfunctional requirements as well?

You can use any function, algorithm and/or data structure which solve the problem within the required time and memory limits. Probably you are a bit confused by the name “best submissions”. As I said, they are sorted based on time efficiency, but they don’t necessarily represent the “best” in terms of code quality or production readiness. We simply need to use some objective criteria in order to sort them (in my opinion it will be more confusing if they are not sorted at all). Once you join one of our Alpha programs the trainers will give their best to explain that there is simply no such thing as “best overall solution” and it is always about achieving the right balance (in terms of efficiency, clean code, maintainability and many more). I hope that it makes more sense now.

1 Like

thanks, here is an example of slower vs faster, " Rotate List" task:

faster: ( Time: 0.007 s, the current best version)


const getGets = arr => {
let index = 0

return () => {
  const toReturn = arr[index]
  index += 1
  return toReturn
}

}
// this is the test

const test = [‘5,3,2,1’,‘2’]
const gets = this.gets || getGets(test)
const print = this.print || console.log

let list1 = gets().split(’,’).map(Number);
let arr = [];
let n = gets();

for (let i = 0; i < list1.length; i++) {
arr.push(list1[i]);
}

function rotate(nums, n) {
n = n % nums.length;
return nums.slice(n).concat(nums.slice(0, n))
}
arr = rotate(arr, n);

let str = “”;

for (let i = 0; i < arr.length; i++) {
if(i != arr.length - 1){
str += arr[i] + “,”;
}
else{
str += arr[i];
}
}
print(str);


slower: ( Time: 0.009 s, my version)


let numList = gets();
let rotatorN = +gets();

numList = numList.split(’,’);

if(rotatorN > numList.length)
rotatorN -= numList.length;

while(rotatorN) {
numList.push(numList.shift());
rotatorN–;
}
print(numList.toString());


Less lines of code doesn’t mean better code. Surely you realize it is an automated system that checks these tasks and it’s not just one lonely person sitting day in and day out looking through every submission manually. The judge system has no concept of the code itself, it purely compares expected output to your output and checks how long it took. The fact that the built in functions take a bit more time than a more direct solution should give you the indication that there is some overhead that you need to consider whatever you do. The fact that the code is easier to understand doesn’t mean anything to the judge system. Also, you’re approaching this with the wrong attitude. You’re angry at an automated system for letting you know that your code takes x amount of seconds to run. There isn’t any better way to list best submissions because the term “best” is subjective and a piece of code does not have any sort of context other than the time it took and whether it was right or wrong.

Thanks for the thorough feedback.
No attitude at all :slight_smile: just curiosity:)