File tree Expand file tree Collapse file tree 1 file changed +16
-16
lines changed Expand file tree Collapse file tree 1 file changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -57,22 +57,22 @@ cmd.handler = function(argv) {
5757 // show beat ratio
5858 if ( ok ) {
5959 core . getSubmission ( { id : result . id } , function ( e , submission ) {
60- if ( submission . distributionChart ) {
61- var beatRatio = 0.0 ;
62- var chart = submission . distributionChart . distribution ;
63- var lang = submission . distributionChart . lang ;
64- for ( var i in chart ) {
65- if ( parseFloat ( chart [ i ] [ 0 ] ) <= parseFloat ( result . display_runtime ) ) {
66- continue ;
67- } else {
68- beatRatio += parseFloat ( chart [ i ] [ 1 ] ) ;
69- }
70- }
71- line = util . format ( ' Your runtime beats %d %% of %s submissions' ,
72- beatRatio . toFixed ( 2 ) ,
73- lang ) ;
74- log . info ( INDENT + h . prettyText ( line , ok ) ) ;
75- }
60+ if ( ! submission . distributionChart ) return ;
61+
62+ var lang = submission . distributionChart . lang ;
63+ var scores = submission . distributionChart . distribution ;
64+ var myRuntime = parseFloat ( result . status_runtime ) ;
65+
66+ var ratio = 0.0 ;
67+ scores . forEach ( function ( score ) {
68+ if ( parseFloat ( score [ 0 ] ) > myRuntime )
69+ ratio += parseFloat ( score [ 1 ] ) ;
70+ } ) ;
71+
72+ line = util . format ( ' Your runtime beats %d %% of %s submissions' ,
73+ ratio . toFixed ( 2 ) ,
74+ lang ) ;
75+ log . info ( INDENT + h . prettyText ( line , ok ) ) ;
7676 } ) ;
7777 }
7878
You can’t perform that action at this time.
0 commit comments