File tree Expand file tree Collapse file tree 3 files changed +46
-45
lines changed
src/hackerrank/interview_preparation_kit/greedy_algorithms Expand file tree Collapse file tree 3 files changed +46
-45
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class Contest {
3939 }
4040}
4141
42- export function luckBalance ( k , contests ) {
42+ function luckBalance ( k , contests ) {
4343 let importantContests = [ ] ;
4444 const nonimportantContests = [ ] ;
4545
Original file line number Diff line number Diff line change 11import { describe , expect , it } from '@jest/globals' ;
22import { logger as console } from '../../../logger.js' ;
33
4- import { luckBalance } from './luck-balance.js' ;
4+ import luckBalance from './luck-balance.js' ;
55
6- const TEST_CASES = [
7- {
8- 'title' : 'Sample Test case 0' ,
9- 'k' : 3 ,
10- 'contests' : [
11- [ 5 , 1 ] ,
12- [ 2 , 1 ] ,
13- [ 1 , 1 ] ,
14- [ 8 , 1 ] ,
15- [ 10 , 0 ] ,
16- [ 5 , 0 ]
17- ] ,
18- 'expected' : 29
19- } ,
20- {
21- 'title' : 'Sample Test case 1' ,
22- 'k' : 5 ,
23- 'contests' : [
24- [ 13 , 1 ] ,
25- [ 10 , 1 ] ,
26- [ 9 , 1 ] ,
27- [ 8 , 1 ] ,
28- [ 13 , 1 ] ,
29- [ 12 , 1 ] ,
30- [ 18 , 1 ] ,
31- [ 13 , 1 ]
32- ] ,
33- 'expected' : 42
34- } ,
35- {
36- 'title' : 'Sample Test case 1' ,
37- 'k' : 2 ,
38- 'contests' : [
39- [ 5 , 1 ] ,
40- [ 4 , 0 ] ,
41- [ 6 , 1 ] ,
42- [ 2 , 1 ] ,
43- [ 8 , 0 ]
44- ] ,
45- 'expected' : 21
46- }
47- ] ;
6+ import TEST_CASES from './luck-balance.testcases.json' ;
487
498describe ( 'luck-balance' , ( ) => {
509 it ( 'luckBalance test cases' , ( ) => {
5110 expect . assertions ( 3 ) ;
5211
5312 TEST_CASES . forEach ( ( test ) => {
54- const answer = luckBalance ( test . k , test . contests ) ;
13+ const answer = luckBalance . luckBalance ( test . k , test . contests ) ;
5514
5615 console . debug (
5716 `luckBalance(${ test . k } , ${ test . contests } ) solution found: ${ answer } `
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "title" : " Sample Test case 0" ,
4+ "k" : 3 ,
5+ "contests" : [
6+ [5 , 1 ],
7+ [2 , 1 ],
8+ [1 , 1 ],
9+ [8 , 1 ],
10+ [10 , 0 ],
11+ [5 , 0 ]
12+ ],
13+ "expected" : 29
14+ },
15+ {
16+ "title" : " Sample Test case 1" ,
17+ "k" : 5 ,
18+ "contests" : [
19+ [13 , 1 ],
20+ [10 , 1 ],
21+ [9 , 1 ],
22+ [8 , 1 ],
23+ [13 , 1 ],
24+ [12 , 1 ],
25+ [18 , 1 ],
26+ [13 , 1 ]
27+ ],
28+ "expected" : 42
29+ },
30+ {
31+ "title" : " Sample Test case 1" ,
32+ "k" : 2 ,
33+ "contests" : [
34+ [5 , 1 ],
35+ [4 , 0 ],
36+ [6 , 1 ],
37+ [2 , 1 ],
38+ [8 , 0 ]
39+ ],
40+ "expected" : 21
41+ }
42+ ]
You can’t perform that action at this time.
0 commit comments