File tree 3 files changed +46
-45
lines changed
src/hackerrank/interview_preparation_kit/greedy_algorithms
3 files changed +46
-45
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class Contest {
39
39
}
40
40
}
41
41
42
- export function luckBalance ( k , contests ) {
42
+ function luckBalance ( k , contests ) {
43
43
let importantContests = [ ] ;
44
44
const nonimportantContests = [ ] ;
45
45
Original file line number Diff line number Diff line change 1
1
import { describe , expect , it } from '@jest/globals' ;
2
2
import { logger as console } from '../../../logger.js' ;
3
3
4
- import { luckBalance } from './luck-balance.js' ;
4
+ import luckBalance from './luck-balance.js' ;
5
5
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' ;
48
7
49
8
describe ( 'luck-balance' , ( ) => {
50
9
it ( 'luckBalance test cases' , ( ) => {
51
10
expect . assertions ( 3 ) ;
52
11
53
12
TEST_CASES . forEach ( ( test ) => {
54
- const answer = luckBalance ( test . k , test . contests ) ;
13
+ const answer = luckBalance . luckBalance ( test . k , test . contests ) ;
55
14
56
15
console . debug (
57
16
`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