Skip to content

Commit c5686c2

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] [Hacker Rank] implementation exercises.
* standarized interface.
1 parent f571c9b commit c5686c2

15 files changed

+35
-20
lines changed

src/hackerrank/implementation/betweenTwoSets.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @link Problem definition [[docs/hackerrank/implementation/betweenTwoSets.md]]
33
*/
44

5-
export function isFactor(n, group) {
5+
function isFactor(n, group) {
66
let result = true;
77
let i = 0;
88

@@ -19,7 +19,7 @@ export function isFactor(n, group) {
1919
return result;
2020
}
2121

22-
export function factorOf(n, group) {
22+
function factorOf(n, group) {
2323
let result = true;
2424
let i = 0;
2525

@@ -36,7 +36,7 @@ export function factorOf(n, group) {
3636
return result;
3737
}
3838

39-
export function getTotalX(a, b) {
39+
function getTotalX(a, b) {
4040
let max = 0;
4141
for (const j of b) {
4242
if (j > max) max = j;
@@ -53,4 +53,5 @@ export function getTotalX(a, b) {
5353
return result.length;
5454
}
5555

56-
export default { getTotalX };
56+
export default { getTotalX, isFactor, factorOf };
57+
export { getTotalX, isFactor, factorOf };

src/hackerrank/implementation/birthday.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { logger as console } from '../../logger.js';
66

7-
export function birthday(s, d, m) {
7+
function birthday(s, d, m) {
88
let result = 0;
99
console.debug(`s: ${s}`);
1010

@@ -23,3 +23,4 @@ export function birthday(s, d, m) {
2323
}
2424

2525
export default { birthday };
26+
export { birthday };

src/hackerrank/implementation/bonAppetit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { logger as console } from '../../logger.js';
66

7-
export function bonAppetit(bill, k, b) {
7+
function bonAppetit(bill, k, b) {
88
const totalSum = bill.reduce(
99
(previousValue, currentValue) => previousValue + currentValue,
1010
0
@@ -25,3 +25,4 @@ export function bonAppetit(bill, k, b) {
2525
}
2626

2727
export default { bonAppetit };
28+
export { bonAppetit };

src/hackerrank/implementation/breakingRecords.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @link Problem definition [[docs/hackerrank/implementation/breakingRecords.md]]
33
*/
44

5-
export function breakingRecords(scores) {
5+
function breakingRecords(scores) {
66
if (scores.length === 0) {
77
throw new Error('Empty input');
88
}
@@ -29,3 +29,4 @@ export function breakingRecords(scores) {
2929
}
3030

3131
export default { breakingRecords };
32+
export { breakingRecords };

src/hackerrank/implementation/countApplesAndOranges.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @link Problem definition [[docs/hackerrank/implementation/countApplesAndOranges.md]]
33
*/
44

5-
export function countApplesAndOranges(s, t, a, b, apples, oranges) {
5+
function countApplesAndOranges(s, t, a, b, apples, oranges) {
66
let cApples = 0;
77
let cOranges = 0;
88

@@ -26,3 +26,4 @@ export function countApplesAndOranges(s, t, a, b, apples, oranges) {
2626
}
2727

2828
export default { countApplesAndOranges };
29+
export { countApplesAndOranges };

src/hackerrank/implementation/countingValleys.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { logger as console } from '../../logger.js';
66

7-
export function countingValleys(steps, path) {
7+
function countingValleys(steps, path) {
88
const stepList = path.split('');
99
let altitude = 0;
1010
let valleys = 0;
@@ -27,3 +27,4 @@ export function countingValleys(steps, path) {
2727
}
2828

2929
export default { countingValleys };
30+
export { countingValleys };

src/hackerrank/implementation/dayOfProgrammer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { daysInMonthNumber } from '../../constants/index.js';
77

88
const zeroPad = (num, places) => String(num).padStart(places, '0');
99

10-
export function dayOfProgrammer(year) {
10+
function dayOfProgrammer(year) {
1111
const dayToSearch = 256;
1212
let leap;
1313

@@ -51,3 +51,4 @@ export function dayOfProgrammer(year) {
5151
}
5252

5353
export default { dayOfProgrammer };
54+
export { dayOfProgrammer };

src/hackerrank/implementation/divisibleSumPairs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { logger as console } from '../../logger.js';
66

7-
export function divisibleSumPairs(n, k, ar) {
7+
function divisibleSumPairs(n, k, ar) {
88
let pairs = 0;
99
for (let i = 0; i < ar.length; i++) {
1010
for (let j = i + 1; j < ar.length; j++) {
@@ -19,3 +19,4 @@ export function divisibleSumPairs(n, k, ar) {
1919
}
2020

2121
export default { divisibleSumPairs };
22+
export { divisibleSumPairs };

src/hackerrank/implementation/gradingStudents.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @link Problem definition [[docs/hackerrank/implementation/gradingStudents.md]]
33
*/
44

5-
export function gradingStudents(grades) {
5+
function gradingStudents(grades) {
66
const minimum = 38;
77
const roundTo = 5;
88
const result = [];
@@ -23,3 +23,4 @@ export function gradingStudents(grades) {
2323
}
2424

2525
export default { gradingStudents };
26+
export { gradingStudents };

src/hackerrank/implementation/jumpingOnClouds.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { logger as console } from '../../logger.js';
66

7-
export function jumpingOnClouds(c) {
7+
function jumpingOnClouds(c) {
88
let result = 0;
99
let key = 0;
1010

@@ -26,3 +26,4 @@ export function jumpingOnClouds(c) {
2626
}
2727

2828
export default { jumpingOnClouds };
29+
export { jumpingOnClouds };

0 commit comments

Comments
 (0)