The Gateway to Computer Science Excellence
1,044 views
function top_avg(students){
	var len = students.length;
	var top01 = 40;
	if(len > 10000){
		top01 = 80;
	}
	var sum = 0.0;
	for (var i = 0; i < top01; i++) {
		sum += students[i].marks;
	}
	return sum/top01;
}

The above code means, everyone rank will jump suddenly when the $10000^{th}$ user comes, while that’s fine, it can be improved. 

By calculating the $top01$ value dynamically based on the length of `students.length`, just multiply by $0.0001$

Unless its already done. I just checked the $github$.

 

 

posted Feb 14 in Others by Active (1,031 points) | 1,044 views
3
Like
0
Love
0
Haha
0
Wow
0
Angry
0
Sad

2 Comments

Well, the github code is not the actual one we are using now. But still not following the dynamic model due to obvious reasons. Instead we have more set sizes and this will be adjusted based on per year trend.
I see, buckets/sets should work too.
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
51,492 questions
58,553 answers
199,933 comments
111,339 users