diff --git a/src/hackerrank/implementation/betweenTwoSets.ts b/src/hackerrank/implementation/betweenTwoSets.ts index d908ee66..1798bb60 100644 --- a/src/hackerrank/implementation/betweenTwoSets.ts +++ b/src/hackerrank/implementation/betweenTwoSets.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/implementation/betweenTwoSets.md]] */ -export function isFactor(n: number, group: number[]): boolean { +function isFactor(n: number, group: number[]): boolean { let result = true; let i = 0; @@ -19,7 +19,7 @@ export function isFactor(n: number, group: number[]): boolean { return result; } -export function factorOf(n: number, group: number[]): boolean { +function factorOf(n: number, group: number[]): boolean { let result = true; let i = 0; @@ -36,7 +36,7 @@ export function factorOf(n: number, group: number[]): boolean { return result; } -export function getTotalX(a: number[], b: number[]): number { +function getTotalX(a: number[], b: number[]): number { let max = 0; for (const j of b) { if (j > max) max = j; @@ -53,4 +53,5 @@ export function getTotalX(a: number[], b: number[]): number { return result.length; } -export default { getTotalX }; +export default { getTotalX, factorOf, isFactor }; +export { getTotalX, factorOf, isFactor }; diff --git a/src/hackerrank/implementation/birthday.ts b/src/hackerrank/implementation/birthday.ts index 535ae488..9234f7cb 100644 --- a/src/hackerrank/implementation/birthday.ts +++ b/src/hackerrank/implementation/birthday.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function birthday(s: number[], d: number, m: number): number { +function birthday(s: number[], d: number, m: number): number { let result = 0; console.debug(`s: ${s.toString()}`); @@ -23,3 +23,4 @@ export function birthday(s: number[], d: number, m: number): number { } export default { birthday }; +export { birthday }; diff --git a/src/hackerrank/implementation/bonAppetit.ts b/src/hackerrank/implementation/bonAppetit.ts index 6ae02e96..b4d825ae 100644 --- a/src/hackerrank/implementation/bonAppetit.ts +++ b/src/hackerrank/implementation/bonAppetit.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function bonAppetit(bill: number[], k: number, b: number): string { +function bonAppetit(bill: number[], k: number, b: number): string { const totalSum = bill.reduce( (previousValue, currentValue) => previousValue + currentValue, 0 @@ -25,3 +25,4 @@ export function bonAppetit(bill: number[], k: number, b: number): string { } export default { bonAppetit }; +export { bonAppetit }; diff --git a/src/hackerrank/implementation/breakingRecords.ts b/src/hackerrank/implementation/breakingRecords.ts index 0db44d79..8b92ccee 100644 --- a/src/hackerrank/implementation/breakingRecords.ts +++ b/src/hackerrank/implementation/breakingRecords.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/implementation/breakingRecords.md]] */ -export function breakingRecords(scores: number[]): number[] { +function breakingRecords(scores: number[]): number[] { if (scores.length === 0) { throw new Error('Empty input'); } @@ -29,3 +29,4 @@ export function breakingRecords(scores: number[]): number[] { } export default { breakingRecords }; +export { breakingRecords }; diff --git a/src/hackerrank/implementation/countApplesAndOranges.ts b/src/hackerrank/implementation/countApplesAndOranges.ts index f1cdeb58..08a2a3ea 100644 --- a/src/hackerrank/implementation/countApplesAndOranges.ts +++ b/src/hackerrank/implementation/countApplesAndOranges.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/implementation/countApplesAndOranges.md]] */ -export function countApplesAndOranges( +function countApplesAndOranges( s: number, t: number, a: number, @@ -33,3 +33,4 @@ export function countApplesAndOranges( } export default { countApplesAndOranges }; +export { countApplesAndOranges }; diff --git a/src/hackerrank/implementation/countingValleys.ts b/src/hackerrank/implementation/countingValleys.ts index 86cd992f..afdb6d79 100644 --- a/src/hackerrank/implementation/countingValleys.ts +++ b/src/hackerrank/implementation/countingValleys.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function countingValleys(steps: number, path: string): number { +function countingValleys(steps: number, path: string): number { const stepList = path.split(''); let altitude = 0; let valleys = 0; @@ -27,3 +27,4 @@ export function countingValleys(steps: number, path: string): number { } export default { countingValleys }; +export { countingValleys }; diff --git a/src/hackerrank/implementation/dayOfProgrammer.ts b/src/hackerrank/implementation/dayOfProgrammer.ts index 713d8c20..7ccca7b0 100644 --- a/src/hackerrank/implementation/dayOfProgrammer.ts +++ b/src/hackerrank/implementation/dayOfProgrammer.ts @@ -8,7 +8,7 @@ import { MonthNumbers, daysInMonthNumber } from '../../constants'; const zeroPad = (num: number, places: number): string => String(num).padStart(places, '0'); -export function dayOfProgrammer(year: number): string { +function dayOfProgrammer(year: number): string { const dayToSearch = 256; let leap: number; @@ -52,3 +52,4 @@ export function dayOfProgrammer(year: number): string { } export default { dayOfProgrammer }; +export { dayOfProgrammer }; diff --git a/src/hackerrank/implementation/divisibleSumPairs.ts b/src/hackerrank/implementation/divisibleSumPairs.ts index 3dc8d892..e38607cb 100644 --- a/src/hackerrank/implementation/divisibleSumPairs.ts +++ b/src/hackerrank/implementation/divisibleSumPairs.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function divisibleSumPairs(n: number, k: number, ar: number[]): number { +function divisibleSumPairs(n: number, k: number, ar: number[]): number { let pairs = 0; for (let i = 0; i < ar.length; i++) { for (let j = i + 1; j < ar.length; j++) { @@ -19,3 +19,4 @@ export function divisibleSumPairs(n: number, k: number, ar: number[]): number { } export default { divisibleSumPairs }; +export { divisibleSumPairs }; diff --git a/src/hackerrank/implementation/gradingStudents.ts b/src/hackerrank/implementation/gradingStudents.ts index bb328c94..46f31aa6 100644 --- a/src/hackerrank/implementation/gradingStudents.ts +++ b/src/hackerrank/implementation/gradingStudents.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/implementation/gradingStudents.md]] */ -export function gradingStudents(grades: number[]): number[] { +function gradingStudents(grades: number[]): number[] { const minimum = 38; const roundTo = 5; const result: number[] = []; @@ -23,3 +23,4 @@ export function gradingStudents(grades: number[]): number[] { } export default { gradingStudents }; +export { gradingStudents }; diff --git a/src/hackerrank/implementation/jumpingOnClouds.ts b/src/hackerrank/implementation/jumpingOnClouds.ts index c8dae473..db96140e 100644 --- a/src/hackerrank/implementation/jumpingOnClouds.ts +++ b/src/hackerrank/implementation/jumpingOnClouds.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function jumpingOnClouds(c: number[]): number { +function jumpingOnClouds(c: number[]): number { let result = 0; let key = 0; @@ -26,3 +26,4 @@ export function jumpingOnClouds(c: number[]): number { } export default { jumpingOnClouds }; +export { jumpingOnClouds }; diff --git a/src/hackerrank/implementation/kangaroo.ts b/src/hackerrank/implementation/kangaroo.ts index 85f9a0db..c0f0d0f6 100644 --- a/src/hackerrank/implementation/kangaroo.ts +++ b/src/hackerrank/implementation/kangaroo.ts @@ -2,12 +2,7 @@ * @link Problem definition [[docs/hackerrank/implementation/kangaroo.md]] */ -export function kangaroo( - x1: number, - v1: number, - x2: number, - v2: number -): string { +function kangaroo(x1: number, v1: number, x2: number, v2: number): string { if (v1 === v2) { if (x1 !== x2) return 'NO'; return 'YES'; @@ -23,3 +18,4 @@ export function kangaroo( } export default { kangaroo }; +export { kangaroo }; diff --git a/src/hackerrank/implementation/migratoryBirds.ts b/src/hackerrank/implementation/migratoryBirds.ts index 911f2c89..bd7a14fc 100644 --- a/src/hackerrank/implementation/migratoryBirds.ts +++ b/src/hackerrank/implementation/migratoryBirds.ts @@ -6,7 +6,7 @@ import { logger as console } from '../../logger'; type Birds = Record; -export function migratoryBirds(arr: number[]): number { +function migratoryBirds(arr: number[]): number { if (arr.length === 0) { throw new Error('Empty input'); } @@ -36,3 +36,4 @@ export function migratoryBirds(arr: number[]): number { } export default { migratoryBirds }; +export { migratoryBirds }; diff --git a/src/hackerrank/implementation/minimumAbsoluteDifference.ts b/src/hackerrank/implementation/minimumAbsoluteDifference.ts index fca61a21..1aaa186d 100644 --- a/src/hackerrank/implementation/minimumAbsoluteDifference.ts +++ b/src/hackerrank/implementation/minimumAbsoluteDifference.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function minimumAbsoluteDifference(arr: number[]): number { +function minimumAbsoluteDifference(arr: number[]): number { if (arr.length === 0) { throw new Error('Empty input'); } @@ -31,3 +31,4 @@ export function minimumAbsoluteDifference(arr: number[]): number { } export default { minimumAbsoluteDifference }; +export { minimumAbsoluteDifference }; diff --git a/src/hackerrank/implementation/repeatedString.ts b/src/hackerrank/implementation/repeatedString.ts index 9a4ad111..54e47327 100644 --- a/src/hackerrank/implementation/repeatedString.ts +++ b/src/hackerrank/implementation/repeatedString.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function countAs(word: string): number { +function countAs(word: string): number { let result = 0; const chars = word.split(''); @@ -18,7 +18,7 @@ export function countAs(word: string): number { return result; } -export function repeatedString(s: string, n: number): number { +function repeatedString(s: string, n: number): number { let result = 0; const blockSize = s.length; @@ -32,4 +32,5 @@ export function repeatedString(s: string, n: number): number { return result; } -export default { countAs }; +export default { countAs, repeatedString }; +export { countAs, repeatedString }; diff --git a/src/hackerrank/implementation/sockMerchant.ts b/src/hackerrank/implementation/sockMerchant.ts index 94fea662..92bd591a 100644 --- a/src/hackerrank/implementation/sockMerchant.ts +++ b/src/hackerrank/implementation/sockMerchant.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function sockMerchant(n: number, ar: number[]): number { +function sockMerchant(n: number, ar: number[]): number { let result = 0; type Matches = Record; @@ -27,3 +27,4 @@ export function sockMerchant(n: number, ar: number[]): number { } export default { sockMerchant }; +export { sockMerchant }; diff --git a/src/hackerrank/interview_preparation_kit/arrays/2d_array.ts b/src/hackerrank/interview_preparation_kit/arrays/2d_array.ts index 333e404c..241b3c49 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/2d_array.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/2d_array.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/2d_array.md]] */ -export function gethourGlass( +function gethourGlass( arr: number[][], positionX: number, positionY: number @@ -22,7 +22,7 @@ export function gethourGlass( return result; } -export function hourglassSum(arr: number[][]): number | null { +function hourglassSum(arr: number[][]): number | null { let matrixSize = 0; if (arr?.[0]) { @@ -65,3 +65,4 @@ export function hourglassSum(arr: number[][]): number | null { } export default { hourglassSum }; +export { hourglassSum }; diff --git a/src/hackerrank/interview_preparation_kit/arrays/cruch_bruteforce.ts b/src/hackerrank/interview_preparation_kit/arrays/cruch_bruteforce.ts index 4ebdf654..746fa7ad 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/cruch_bruteforce.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/cruch_bruteforce.ts @@ -5,7 +5,7 @@ import { logger as console } from '../../../logger'; -export function arrayManipulation(n: number, queries: number[][]): number { +function arrayManipulation(n: number, queries: number[][]): number { const LENGTH = n + 1; const SURROGATE_VALUE = 0; const result: number[] = Array(LENGTH).fill(SURROGATE_VALUE); @@ -29,3 +29,4 @@ export function arrayManipulation(n: number, queries: number[][]): number { } export default { arrayManipulation }; +export { arrayManipulation }; diff --git a/src/hackerrank/interview_preparation_kit/arrays/cruch_optimized.ts b/src/hackerrank/interview_preparation_kit/arrays/cruch_optimized.ts index a95f77db..07c3634e 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/cruch_optimized.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/cruch_optimized.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/crush.md]] */ -export function arrayManipulation(n: number, queries: number[][]): number { +function arrayManipulation(n: number, queries: number[][]): number { // why adding 2? // first slot to adjust 1-based index and // last slot for storing accumSum result @@ -29,3 +29,4 @@ export function arrayManipulation(n: number, queries: number[][]): number { } export default { arrayManipulation }; +export { arrayManipulation }; diff --git a/src/hackerrank/interview_preparation_kit/arrays/cruch_testcases_test.json b/src/hackerrank/interview_preparation_kit/arrays/cruch_testcases_test.json index ec7d19ca..fa4f8a1d 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/cruch_testcases_test.json +++ b/src/hackerrank/interview_preparation_kit/arrays/cruch_testcases_test.json @@ -3,21 +3,9 @@ "title": "Sample Test Case 0", "n": 5, "queries": [ - [ - 1, - 2, - 100 - ], - [ - 2, - 5, - 100 - ], - [ - 3, - 4, - 100 - ] + [1, 2, 100], + [2, 5, 100], + [3, 4, 100] ], "expected": 200 }, @@ -25,21 +13,9 @@ "title": "Sample Test Case 1", "n": 10, "queries": [ - [ - 1, - 5, - 3 - ], - [ - 4, - 8, - 7 - ], - [ - 6, - 9, - 1 - ] + [1, 5, 3], + [4, 8, 7], + [6, 9, 1] ], "expected": 10 }, @@ -47,26 +23,10 @@ "title": "Sample Test Case 3", "n": 10, "queries": [ - [ - 2, - 6, - 8 - ], - [ - 3, - 5, - 7 - ], - [ - 1, - 8, - 1 - ], - [ - 5, - 9, - 15 - ] + [2, 6, 8], + [3, 5, 7], + [1, 8, 1], + [5, 9, 15] ], "expected": 31 } diff --git a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts index b47a9fec..72c93082 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts @@ -1,41 +1,31 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger'; -import { rotLeft, rotLeftOne } from './ctci_array_left_rotation'; +import { rotLeft } from './ctci_array_left_rotation'; -import ROT_LEFT_ONE_TEST_CASES from './ctci_array_left_rotation.testcases.json'; +import ROT_LEFT_TEST_CASES from './ctci_array_left_rotation.testcases.json'; -describe('ctci_array_left_rotation', () => { - it('rotLeftOne Test Cases', () => { - expect.assertions(5); - - ROT_LEFT_ONE_TEST_CASES.forEach((test) => { - const input = test.numbers; - const answer = rotLeftOne(input); +interface RotLeftTestCase { + title: string; + input: number[]; + d_rotations: number; + expected: number[]; +} - console.debug( - `rotLeftOne(${test.numbers.toString()}) solution found: ${answer.toString()}` - ); - - expect(answer).toStrictEqual(test.expected); - }); - }); +const TEST_CASES: RotLeftTestCase[] = ROT_LEFT_TEST_CASES as RotLeftTestCase[]; +describe('ctci_array_left_rotation', () => { it('rotLeft Test cases', () => { - expect.assertions(1); + expect.assertions(8); - const ROT_LEFT_TEST_CASES = [ - { numbers: [1, 2, 3, 4, 5], d_rotations: 4, expected: [5, 1, 2, 3, 4] } - ]; - - ROT_LEFT_TEST_CASES.forEach((value) => { - const answer = rotLeft(value.numbers, value.d_rotations); + TEST_CASES.forEach((test: RotLeftTestCase) => { + const answer = rotLeft(test.input, Number(test.d_rotations)); console.debug( - `rotLeft(${value.numbers.toString()}) solution found: ${answer.toString()}` + `rotLeft(${test.input.toString()}) solution found: ${test.expected.toString()}` ); - expect(answer).toStrictEqual(value.expected); + expect(answer).toStrictEqual(test.expected); }); }); }); diff --git a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json index aa06f8ae..086230cf 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json +++ b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json @@ -1,7 +1,10 @@ [ - {"numbers": [1, 2, 3, 4, 5], "expected": [2, 3, 4, 5, 1]}, - {"numbers": [2, 3, 4, 5, 1], "expected": [3, 4, 5, 1, 2]}, - {"numbers": [3, 4, 5, 1, 2], "expected": [4, 5, 1, 2, 3]}, - {"numbers": [4, 5, 1, 2, 3], "expected": [5, 1, 2, 3, 4]}, - {"numbers": [5, 1, 2, 3, 4], "expected": [1, 2, 3, 4, 5]} + {"title": "Own 0", "input": [1, 2, 3, 4, 5], "d_rotations": 1, "expected": [2, 3, 4, 5, 1]}, + {"title": "Own 1", "input": [2, 3, 4, 5, 1], "d_rotations": 1, "expected": [3, 4, 5, 1, 2]}, + {"title": "Own 2", "input": [3, 4, 5, 1, 2], "d_rotations": 1, "expected": [4, 5, 1, 2, 3]}, + {"title": "Own 3", "input": [4, 5, 1, 2, 3], "d_rotations": 1, "expected": [5, 1, 2, 3, 4]}, + {"title": "Own 4", "input": [5, 1, 2, 3, 4], "d_rotations": 1, "expected": [1, 2, 3, 4, 5]}, + {"title": "Sample Test case 0", "input": [1, 2, 3, 4, 5], "d_rotations": 4, "expected": [5, 1, 2, 3, 4]}, + {"title": "Sample Test case 1", "input": [41, 73, 89, 7, 10, 1, 59, 58, 84, 77, 77, 97, 58, 1, 86, 58, 26, 10, 86, 51], "d_rotations": 10, "expected": [77, 97, 58, 1, 86, 58, 26, 10, 86, 51, 41, 73, 89, 7, 10, 1, 59, 58, 84, 77]}, + {"title": "Sample Test case 1", "input": [33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60, 87, 97], "d_rotations": 13, "expected": [87, 97, 33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60]} ] diff --git a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.ts b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.ts index b60de67e..45bac17c 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.md]] */ -export function rotLeftOne(aNumbers: number[]): number[] { +function rotLeftOne(aNumbers: number[]): number[] { const first = aNumbers.shift(); if (first !== undefined) { aNumbers.push(first); @@ -11,7 +11,7 @@ export function rotLeftOne(aNumbers: number[]): number[] { return aNumbers; } -export function rotLeft(aNumbers: number[], dRotations: number): number[] { +function rotLeft(aNumbers: number[], dRotations: number): number[] { let output = [...aNumbers]; for (let i = 0; i < dRotations; i++) { @@ -22,3 +22,4 @@ export function rotLeft(aNumbers: number[], dRotations: number): number[] { } export default { rotLeft, rotLeftOne }; +export { rotLeft }; diff --git a/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.ts b/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.ts index 81f3113c..333ac37f 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.md]] */ -export function minimumSwaps(arr: number[]): number { +function minimumSwaps(arr: number[]): number { const indexedGroup = arr.map((x) => x - 1); let swaps = 0; let index = 0; @@ -23,3 +23,4 @@ export function minimumSwaps(arr: number[]): number { } export default { minimumSwaps }; +export { minimumSwaps }; diff --git a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts index 3c708d9e..51beb1ff 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger'; -import { minimumBribesTransform } from './new_year_chaos'; +import { minimumBribes, minimumBribesText } from './new_year_chaos'; import TEST_CASES from './new_year_chaos.testcases.json'; @@ -10,7 +10,8 @@ describe('new_year_chaos', () => { expect.assertions(5); TEST_CASES.forEach((value) => { - const answer = minimumBribesTransform(value.input); + const answer = minimumBribesText(value.input); + minimumBribes(value.input); console.debug( `minimumBribesTransform(${value.input.toString()}) solution found: ${answer}` diff --git a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json index 5527c31e..1679946f 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json +++ b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json @@ -1,27 +1,27 @@ [ - { - "title": "Test Case 0-0", - "input": [2, 1, 5, 3, 4], - "expected": 3 - }, - { - "title": "Test Case 0-1", - "input": [2, 5, 1, 3, 4], - "expected": "Too chaotic" - }, - { - "title": "Test Case 1-1", - "input": [5, 1, 2, 3, 7, 8, 6, 4], - "expected": "Too chaotic" - }, - { - "title": "Test Case 1-2", - "input": [1, 2, 5, 3, 7, 8, 6, 4], - "expected": 7 - }, - { - "title": "Test Case 2", - "input": [1, 2, 5, 3, 4, 7, 8, 6], - "expected": 4 - } - ] + { + "title": "Test Case 0-0", + "input": [2, 1, 5, 3, 4], + "expected": "3" + }, + { + "title": "Test Case 0-1", + "input": [2, 5, 1, 3, 4], + "expected": "Too chaotic" + }, + { + "title": "Test Case 1-1", + "input": [5, 1, 2, 3, 7, 8, 6, 4], + "expected": "Too chaotic" + }, + { + "title": "Test Case 1-2", + "input": [1, 2, 5, 3, 7, 8, 6, 4], + "expected": "7" + }, + { + "title": "Test Case 2", + "input": [1, 2, 5, 3, 4, 7, 8, 6], + "expected": "4" + } +] diff --git a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.ts b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.ts index b8b39046..ad3ef1e9 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.ts @@ -2,10 +2,10 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/new_year_chaos.md]] */ -export const TOO_CHAOTIC_ERROR = 'Too chaotic'; -export const NEW_YEAR_CHAOS_TOLERANCE = 2; +const TOO_CHAOTIC_ERROR = 'Too chaotic'; +const NEW_YEAR_CHAOS_TOLERANCE = 2; -export function minimumBribes(q: number[]): number { +function minimumBribesCalculate(q: number[]): number { let bribes = 0; let i = 0; @@ -15,7 +15,10 @@ export function minimumBribes(q: number[]): number { throw new Error(TOO_CHAOTIC_ERROR); } - const fragment = q.slice(Math.max(value - NEW_YEAR_CHAOS_TOLERANCE, 0), i); + const fragment = q.slice( + Math.min(Math.max(value - NEW_YEAR_CHAOS_TOLERANCE, 0), i), + i + ); fragment.forEach((k) => { if (k > value) { @@ -28,11 +31,11 @@ export function minimumBribes(q: number[]): number { return bribes; } -export function minimumBribesTransform(queue: number[]): number | string { - let result: number | string = ''; +function minimumBribesText(queue: number[]): string { + let result = ''; try { - result = minimumBribes(queue); + result = `${minimumBribesCalculate(queue)}`; } catch (err: unknown) { if (err instanceof Error) { result = err.message; @@ -42,4 +45,9 @@ export function minimumBribesTransform(queue: number[]): number | string { return result; } -export default { minimumBribes, minimumBribesTransform, TOO_CHAOTIC_ERROR }; +function minimumBribes(q: number[]): void { + console.log(minimumBribesText(q)); +} + +export default { minimumBribes, minimumBribesText, TOO_CHAOTIC_ERROR }; +export { minimumBribes, minimumBribesText, TOO_CHAOTIC_ERROR }; diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts index 2705b840..dc910fb9 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger'; -import { countTriplets } from './count_triplets_1_bruteforce'; +import CountTriplets from './count_triplets_1_bruteforce'; import SMALL_TEST_CASES from './count_triplets_1.small.testcases.json'; @@ -10,7 +10,7 @@ describe('count_triplets_1', () => { expect.assertions(4); SMALL_TEST_CASES.forEach((test) => { - const answer = countTriplets(test.input, test.r); + const answer = CountTriplets.countTriplets(test.input, test.r); console.debug( `countTriplets(${test.input.toString()}, ${test.r}) solution found: ${answer}` diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.ts index ffc33a2c..40780981 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.ts @@ -4,7 +4,7 @@ */ import { logger as console } from '../../../logger'; -export function countTriplets(arr: number[], ratio: number): number { +function countTriplets(arr: number[], ratio: number): number { const size = arr.length; let counter = 0; diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts index ee82d24c..6d3676ed 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger'; -import { countTriplets } from './count_triplets_1_optmized'; +import CountTriplets from './count_triplets_1_optmized'; import SMALL_TEST_CASES from './count_triplets_1.small.testcases.json'; import BIG_TEST_CASES from './count_triplets_1.big.testcases.json'; @@ -11,7 +11,7 @@ describe('count_triplets_1 (optimized)', () => { expect.assertions(4); SMALL_TEST_CASES.forEach((test) => { - const answer = countTriplets(test.input, test.r); + const answer = CountTriplets.countTriplets(test.input, test.r); console.debug( `countTriplets(${test.input.toString()}, ${test.r}) solution found: ${answer}` @@ -25,7 +25,7 @@ describe('count_triplets_1 (optimized)', () => { expect.assertions(1); BIG_TEST_CASES.forEach((test) => { - const answer = countTriplets(test.input, test.r); + const answer = CountTriplets.countTriplets(test.input, test.r); console.debug( `countTriplets(${test.input.toString()}, ${test.r}) solution found: ${answer}` diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optmized.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optmized.ts index 277a80aa..a20ea6fe 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optmized.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optmized.ts @@ -3,7 +3,7 @@ * @see Solution Notes: [[docs/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1-solution-notes.md]] */ -export function countTriplets(arr: number[], ratio: number): number { +function countTriplets(arr: number[], ratio: number): number { let triplets = 0; const aCounter: Record = arr.reduce( diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.ts index cd6ca0b6..7618a67e 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.ts @@ -5,10 +5,7 @@ const __YES__ = 'Yes'; const __NO__ = 'No'; -export function checkMagazineCompute( - magazine: string[], - note: string[] -): boolean { +function checkMagazineCompute(magazine: string[], note: string[]): boolean { const dictionary: Record = {}; for (const word of magazine) { @@ -30,8 +27,9 @@ export function checkMagazineCompute( return true; } -export function checkMagazine(magazine: string[], note: string[]): string { +function checkMagazine(magazine: string[], note: string[]): string { return checkMagazineCompute(magazine, note) ? __YES__ : __NO__; } export default { checkMagazine }; +export { checkMagazine }; diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_bruteforce.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_bruteforce.ts index fd65d58b..c34643af 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_bruteforce.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_bruteforce.ts @@ -4,7 +4,7 @@ */ // Complete the freqQuery function below. -export function freqQuery(queries: number[][]): number[] { +function freqQuery(queries: number[][]): number[] { const result: number[] = []; const dataMap: Record = {}; @@ -46,3 +46,4 @@ export function freqQuery(queries: number[][]): number[] { } export default { freqQuery }; +export { freqQuery }; diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_optimized.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_optimized.ts index 13a86325..aabeb9f7 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_optimized.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency_queries_optimized.ts @@ -3,7 +3,7 @@ * @see Solution Notes: [[docs/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/frequency-queries-solution-notes.md]] */ -export function updateFrequency( +function updateFrequency( frequencyMap: Record, data: number, currentFreq: number, @@ -32,7 +32,7 @@ export function updateFrequency( return freqMap; } -export function freqQuery(queries: number[][]): number[] { +function freqQuery(queries: number[][]): number[] { const result: number[] = []; const dataMap: Record = {}; const freqMap: Record = {}; @@ -88,3 +88,4 @@ export function freqQuery(queries: number[][]): number[] { } export default { freqQuery }; +export { freqQuery }; diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/sherlock_and_anagrams.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/sherlock_and_anagrams.ts index b5a93801..91c07b1c 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/sherlock_and_anagrams.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/sherlock_and_anagrams.ts @@ -10,7 +10,7 @@ function extraLongFactorials(n: number): bigint { return rs; } -export function sherlockAndAnagrams(s: string): number { +function sherlockAndAnagrams(s: string): number { const candidates: Record = {}; const size = s.length; @@ -66,3 +66,4 @@ export function sherlockAndAnagrams(s: string): number { } export default { sherlockAndAnagrams }; +export { sherlockAndAnagrams }; diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.ts index 878e7caa..bbcd9074 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.ts @@ -5,7 +5,7 @@ const __YES__ = 'YES'; const __NO__ = 'NO'; -export function twoStringsCompute(s1: string, s2: string): boolean { +function twoStringsCompute(s1: string, s2: string): boolean { for (const char of s1) { if (s2.includes(char)) { return true; @@ -14,8 +14,9 @@ export function twoStringsCompute(s1: string, s2: string): boolean { return false; } -export function twoStrings(s1: string, s2: string): string { +function twoStrings(s1: string, s2: string): string { return twoStringsCompute(s1, s2) ? __YES__ : __NO__; } export default { twoStrings }; +export { twoStrings }; diff --git a/src/hackerrank/interview_preparation_kit/dynamic_programming/max_array_sum.ts b/src/hackerrank/interview_preparation_kit/dynamic_programming/max_array_sum.ts index 06aaafde..d6e1c0f3 100644 --- a/src/hackerrank/interview_preparation_kit/dynamic_programming/max_array_sum.ts +++ b/src/hackerrank/interview_preparation_kit/dynamic_programming/max_array_sum.ts @@ -6,7 +6,7 @@ const bigIntMax = (...args: bigint[]): bigint => args.reduce((m, e) => (e > m ? e : m), BigInt(0)); -export function maxSubsetSum(arr: number[]): number { +function maxSubsetSum(arr: number[]): number { const arrCopy: bigint[] = arr.map((x: number): bigint => BigInt(x)); if (arrCopy.length === 0) { @@ -32,3 +32,4 @@ export function maxSubsetSum(arr: number[]): number { } export default { maxSubsetSum }; +export { maxSubsetSum }; diff --git a/src/hackerrank/interview_preparation_kit/greedy_algorithms/angry_children.ts b/src/hackerrank/interview_preparation_kit/greedy_algorithms/angry_children.ts index 58d89667..a001ecdb 100644 --- a/src/hackerrank/interview_preparation_kit/greedy_algorithms/angry_children.ts +++ b/src/hackerrank/interview_preparation_kit/greedy_algorithms/angry_children.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/greedy_algorithms/angry-children.md]] */ -export function maxMin(k: number, arr: number[]): number { +function maxMin(k: number, arr: number[]): number { const sortedlist = arr .map((x: number): number => x) .sort((a: number, b: number): number => a - b); @@ -19,3 +19,4 @@ export function maxMin(k: number, arr: number[]): number { } export default { maxMin }; +export { maxMin }; diff --git a/src/hackerrank/interview_preparation_kit/greedy_algorithms/greedy_florist.ts b/src/hackerrank/interview_preparation_kit/greedy_algorithms/greedy_florist.ts index d4e3d698..d5d65d3f 100644 --- a/src/hackerrank/interview_preparation_kit/greedy_algorithms/greedy_florist.ts +++ b/src/hackerrank/interview_preparation_kit/greedy_algorithms/greedy_florist.ts @@ -3,7 +3,7 @@ * @see Solution Notes: [[docs/hackerrank/interview_preparation_kit/greedy_algorithms/greedy-florist-solution-notes.md]] */ -export function getMinimumCost(k: number, c: number[]): number { +function getMinimumCost(k: number, c: number[]): number { const flowers = c .map((x: number): number => x) .sort((a: number, b: number): number => b - a); @@ -22,3 +22,4 @@ export function getMinimumCost(k: number, c: number[]): number { } export default { getMinimumCost }; +export { getMinimumCost }; diff --git a/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts index dc3b023b..d1059c86 100644 --- a/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts +++ b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger'; -import { luckBalance } from './luck-balance'; +import luckBalance from './luck-balance'; import TEST_CASES from './luck-balance.testcases.json'; @@ -10,7 +10,7 @@ describe('luck-balance', () => { expect.assertions(3); TEST_CASES.forEach((test) => { - const answer = luckBalance(test.k, test.contests); + const answer = luckBalance.luckBalance(test.k, test.contests); console.debug( `luckBalance(${test.k}, ${test.contests.toString()}) solution found: ${answer}` diff --git a/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.ts b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.ts index fc27db62..2f1a5150 100644 --- a/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.ts +++ b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.ts @@ -42,7 +42,7 @@ function dynamicSort(array: T[], sortBy: SortBy[]): T[] { ); } -export function luckBalance(k: number, contests: number[][]): number { +function luckBalance(k: number, contests: number[][]): number { let importantContests: Contest[] = []; const nonimportantContests: Contest[] = []; diff --git a/src/hackerrank/interview_preparation_kit/greedy_algorithms/minimum_absolute_difference_in_an_array.ts b/src/hackerrank/interview_preparation_kit/greedy_algorithms/minimum_absolute_difference_in_an_array.ts index bde87be0..7d57f51d 100644 --- a/src/hackerrank/interview_preparation_kit/greedy_algorithms/minimum_absolute_difference_in_an_array.ts +++ b/src/hackerrank/interview_preparation_kit/greedy_algorithms/minimum_absolute_difference_in_an_array.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/greedy_algorithms/minimum-absolute-difference-in-an-array.md]] */ -export function minimumAbsoluteDifference(arr: number[]): number { +function minimumAbsoluteDifference(arr: number[]): number { const sortedNums = arr .map((x: number): number => x) .sort((a: number, b: number): number => b - a); @@ -22,3 +22,4 @@ export function minimumAbsoluteDifference(arr: number[]): number { } export default { minimumAbsoluteDifference }; +export { minimumAbsoluteDifference }; diff --git a/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.ts b/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.ts index 7e3b9e25..17a2cda8 100644 --- a/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.ts +++ b/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.ts @@ -5,7 +5,7 @@ const __BINARY_BASE__ = 2; const __NUMBER_SIZE_IN_BITS__ = 32; -export function flippingBits(n: number): number { +function flippingBits(n: number): number { let nBinaryStr = n.toString(__BINARY_BASE__); nBinaryStr = nBinaryStr.padStart(__NUMBER_SIZE_IN_BITS__, '0'); @@ -23,3 +23,4 @@ export function flippingBits(n: number): number { } export default { flippingBits }; +export { flippingBits }; diff --git a/src/hackerrank/interview_preparation_kit/miscellaneous/friend_circle_queries.ts b/src/hackerrank/interview_preparation_kit/miscellaneous/friend_circle_queries.ts index e06097db..1921745e 100644 --- a/src/hackerrank/interview_preparation_kit/miscellaneous/friend_circle_queries.ts +++ b/src/hackerrank/interview_preparation_kit/miscellaneous/friend_circle_queries.ts @@ -56,7 +56,7 @@ class GropingFriends { } } -export function maxCircle(queries: number[][]): number[] { +function maxCircle(queries: number[][]): number[] { const result: number[] = []; const friends = new GropingFriends(); @@ -72,3 +72,4 @@ export function maxCircle(queries: number[][]): number[] { } export default { maxCircle }; +export { maxCircle }; diff --git a/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_fibonacci_numbers.ts b/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_fibonacci_numbers.ts index 4b14fb17..c6755c92 100644 --- a/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_fibonacci_numbers.ts +++ b/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_fibonacci_numbers.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_fibonacci_numbers.md]] */ -export function fibonacci(n: number): number { +function fibonacci(n: number): number { if (n === 0) { return 0; } @@ -14,3 +14,4 @@ export function fibonacci(n: number): number { } export default { fibonacci }; +export { fibonacci }; diff --git a/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_recursive_staircase.ts b/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_recursive_staircase.ts index dc72c2b6..f77ac8ca 100644 --- a/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_recursive_staircase.ts +++ b/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/ctci_recursive_staircase.ts @@ -6,7 +6,7 @@ const TOP_LIMIT = 10 ** 10 + 7; const STEPS_LIMIT = 3; -export class StepPerms { +class StepPerms { TOP_LIMIT = 1; STEPS_LIMIT = 1; @@ -39,10 +39,11 @@ export class StepPerms { } } -export function stepPerms(n: number): number { +function stepPerms(n: number): number { const stairs = new StepPerms(TOP_LIMIT, STEPS_LIMIT); return stairs.step_perms_comput_with_cache(n) % TOP_LIMIT; } export default { stepPerms, StepPerms }; +export { stepPerms, StepPerms }; diff --git a/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/recursive_digit_sum.ts b/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/recursive_digit_sum.ts index c307b6fd..6c6d89f5 100644 --- a/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/recursive_digit_sum.ts +++ b/src/hackerrank/interview_preparation_kit/recursion_and_backtracking/recursive_digit_sum.ts @@ -4,7 +4,7 @@ const __RADIX__ = 10; -export function superDigitCompute(n: string): number { +function superDigitCompute(n: string): number { if (n.length === 1) { return parseInt(n, __RADIX__); } @@ -17,7 +17,7 @@ export function superDigitCompute(n: string): number { return superDigitCompute(`${partial}`); } -export function superDigit(n: string, k: number): number { +function superDigit(n: string, k: number): number { const accumulator = `${superDigitCompute(n)}`; let result = ''; @@ -29,3 +29,4 @@ export function superDigit(n: string, k: number): number { } export default { superDigit }; +export { superDigit }; diff --git a/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor.ts b/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor.ts index 2c34477d..b6220295 100644 --- a/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor.ts +++ b/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor.ts @@ -4,10 +4,7 @@ const __RADIX__ = 10; -export function whatFlavorsCompute( - cost: number[], - money: number -): number[] | null { +function whatFlavorsCompute(cost: number[], money: number): number[] | null { const cache: Record = {}; for (const [key, price] of Object.entries(cost)) { @@ -24,8 +21,9 @@ export function whatFlavorsCompute( return []; } -export function whatFlavors(cost: number[], money: number): void { +function whatFlavors(cost: number[], money: number): void { console.log(whatFlavorsCompute(cost, money)?.join(' ')); } export default { whatFlavorsCompute, whatFlavors }; +export { whatFlavorsCompute, whatFlavors }; diff --git a/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_bruteforce.ts b/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_bruteforce.ts index 9f732a86..9b2f527c 100644 --- a/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_bruteforce.ts +++ b/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_bruteforce.ts @@ -2,10 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/search/ctci-ice-cream-parlor.md]] */ -export function whatFlavorsBruteforceCompute( - cost: number[], - money: number -): number[] { +function whatFlavorsBruteforceCompute(cost: number[], money: number): number[] { const RADIX = 10; for (const key of Object.keys(cost)) { @@ -25,8 +22,9 @@ export function whatFlavorsBruteforceCompute( return []; } -export function whatFlavors(cost: number[], money: number): void { +function whatFlavors(cost: number[], money: number): void { console.log(whatFlavorsBruteforceCompute(cost, money)?.join(' ')); } export default { whatFlavorsBruteforceCompute, whatFlavors }; +export { whatFlavorsBruteforceCompute, whatFlavors }; diff --git a/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_optimized.ts b/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_optimized.ts index c27fcdc1..1dcf0cb8 100644 --- a/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_optimized.ts +++ b/src/hackerrank/interview_preparation_kit/search/ctci_ice_cream_parlor_optimized.ts @@ -4,7 +4,7 @@ const __RADIX__ = 10; -export function whatFlavorsCompute(cost: number[], money: number): number[] { +function whatFlavorsCompute(cost: number[], money: number): number[] { let ans1: number | null = null; let ans2: number | null = null; @@ -45,8 +45,9 @@ export function whatFlavorsCompute(cost: number[], money: number): number[] { return Array.from(result); } -export function whatFlavors(cost: number[], money: number): void { +function whatFlavors(cost: number[], money: number): void { console.log(whatFlavorsCompute(cost, money)?.join(' ')); } export default { whatFlavorsCompute, whatFlavors }; +export { whatFlavorsCompute, whatFlavors }; diff --git a/src/hackerrank/interview_preparation_kit/search/swap_nodes_algo.ts b/src/hackerrank/interview_preparation_kit/search/swap_nodes_algo.ts index 5e4476c9..6325db7d 100644 --- a/src/hackerrank/interview_preparation_kit/search/swap_nodes_algo.ts +++ b/src/hackerrank/interview_preparation_kit/search/swap_nodes_algo.ts @@ -5,12 +5,12 @@ import { Node } from '../../lib/Node'; // CONSTANTS -export const __INITIAL_LEVEL__ = 1; -export const __ROOT_VALUE__ = 1; -export const __LEAF_VALUE__ = -1; +const __INITIAL_LEVEL__ = 1; +const __ROOT_VALUE__ = 1; +const __LEAF_VALUE__ = -1; const __RADIX__ = 10; -export class Tree { +class Tree { root: Node; nodeCollector: Record[]>; @@ -97,7 +97,7 @@ export class Tree { } } -export function swapNodes(indexes: number[][], queries: number[]): number[][] { +function swapNodes(indexes: number[][], queries: number[]): number[][] { const tree: Tree = new Tree(indexes); let nodeCollector: Record[]> = tree.getCollector(); const output: number[][] = []; @@ -126,4 +126,5 @@ export function swapNodes(indexes: number[][], queries: number[]): number[][] { return output; } -export default { swapNodes, __INITIAL_LEVEL__ }; +export default { swapNodes, Tree, __INITIAL_LEVEL__ }; +export { swapNodes, Tree, __INITIAL_LEVEL__ }; diff --git a/src/hackerrank/interview_preparation_kit/sort/ctci_bubble_sort.ts b/src/hackerrank/interview_preparation_kit/sort/ctci_bubble_sort.ts index d9f02118..36f79ff8 100644 --- a/src/hackerrank/interview_preparation_kit/sort/ctci_bubble_sort.ts +++ b/src/hackerrank/interview_preparation_kit/sort/ctci_bubble_sort.ts @@ -4,7 +4,7 @@ const SEPARATOR = '\n'; -export class SortableGroup { +class SortableGroup { group: number[]; count: number; @@ -38,7 +38,7 @@ export class SortableGroup { } } -export function countSwaps(a: number[]): void { +function countSwaps(a: number[]): void { const sortableGroup = new SortableGroup(a); sortableGroup.bubble_sort(); @@ -53,3 +53,4 @@ export function countSwaps(a: number[]): void { } export default { countSwaps, SortableGroup }; +export { countSwaps, SortableGroup }; diff --git a/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.Player.ts b/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.Player.ts index eb216efb..88bb0e9d 100644 --- a/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.Player.ts +++ b/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.Player.ts @@ -1,4 +1,4 @@ -export class Player { +class Player { name = ''; score = 0; @@ -14,3 +14,4 @@ export class Player { } export default { Player }; +export { Player }; diff --git a/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.ts b/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.ts index 16fc594c..cb93559b 100644 --- a/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.ts +++ b/src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.ts @@ -4,7 +4,7 @@ import { Player } from './ctci_comparator_sorting.Player'; -export class SortablePlayer extends Player { +class SortablePlayer extends Player { name = ''; score = 0; @@ -34,7 +34,7 @@ export class SortablePlayer extends Player { } } -export function comparatorSorting(players: SortablePlayer[]): string[] { +function comparatorSorting(players: SortablePlayer[]): string[] { const sortedPlayers = [...players].sort( (a: SortablePlayer, b: SortablePlayer): number => a.comparator(b) ); @@ -42,8 +42,15 @@ export function comparatorSorting(players: SortablePlayer[]): string[] { return sortedPlayers.map((player: SortablePlayer) => player.toString()); } -export function comparatorSortingPrint(players: SortablePlayer[]): void { +function comparatorSortingPrint(players: SortablePlayer[]): void { console.log(comparatorSorting(players)?.join('\n')); } -export default { Player, SortablePlayer, comparatorSorting }; +export default { + Player, + SortablePlayer, + comparatorSorting, + comparatorSortingPrint +}; + +export { Player, SortablePlayer, comparatorSorting, comparatorSortingPrint }; diff --git a/src/hackerrank/interview_preparation_kit/sort/mark_and_toys.ts b/src/hackerrank/interview_preparation_kit/sort/mark_and_toys.ts index af165334..209a3bfe 100644 --- a/src/hackerrank/interview_preparation_kit/sort/mark_and_toys.ts +++ b/src/hackerrank/interview_preparation_kit/sort/mark_and_toys.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/sort/mark-and-toys.md]] */ -export function maximumToys(prices: number[], k: number): number { +function maximumToys(prices: number[], k: number): number { const group = [...prices]; group.sort((a: number, b: number) => a - b); @@ -21,3 +21,4 @@ export function maximumToys(prices: number[], k: number): number { } export default { maximumToys }; +export { maximumToys }; diff --git a/src/hackerrank/interview_preparation_kit/stacks_and_queues/balanced_brackets.ts b/src/hackerrank/interview_preparation_kit/stacks_and_queues/balanced_brackets.ts index f682cd28..877b3ca6 100644 --- a/src/hackerrank/interview_preparation_kit/stacks_and_queues/balanced_brackets.ts +++ b/src/hackerrank/interview_preparation_kit/stacks_and_queues/balanced_brackets.ts @@ -5,7 +5,7 @@ const __YES__ = 'YES'; const __NO__ = 'NO'; -export function isBalancedCompute(s: string): boolean { +function isBalancedCompute(s: string): boolean { const pairs: Record = { '{': '}', '(': ')', '[': ']' }; const brackets: string[] = []; @@ -27,8 +27,9 @@ export function isBalancedCompute(s: string): boolean { return brackets.length <= 0; } -export function isBalanced(s: string): string { +function isBalanced(s: string): string { return isBalancedCompute(s) ? __YES__ : __NO__; } export default { isBalanced }; +export { isBalanced }; diff --git a/src/hackerrank/interview_preparation_kit/string_manipulation/alternating_characters.ts b/src/hackerrank/interview_preparation_kit/string_manipulation/alternating_characters.ts index 6f3c430a..744303e9 100644 --- a/src/hackerrank/interview_preparation_kit/string_manipulation/alternating_characters.ts +++ b/src/hackerrank/interview_preparation_kit/string_manipulation/alternating_characters.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/string_manipulation/alternating-characters.md]] */ -export function alternatingCharacters(s: string): number { +function alternatingCharacters(s: string): number { let last = ''; let newString = ''; @@ -18,3 +18,4 @@ export function alternatingCharacters(s: string): number { } export default { alternatingCharacters }; +export { alternatingCharacters }; diff --git a/src/hackerrank/interview_preparation_kit/string_manipulation/ctci_making_anagrams.ts b/src/hackerrank/interview_preparation_kit/string_manipulation/ctci_making_anagrams.ts index 7218aa3d..ba824c44 100644 --- a/src/hackerrank/interview_preparation_kit/string_manipulation/ctci_making_anagrams.ts +++ b/src/hackerrank/interview_preparation_kit/string_manipulation/ctci_making_anagrams.ts @@ -20,7 +20,7 @@ function sum(values: number[]): number { ); } -export function makeAnagram(a: string, b: string): number { +function makeAnagram(a: string, b: string): number { const aMap = charToDicMap(a); const bMap = charToDicMap(b); @@ -35,3 +35,4 @@ export function makeAnagram(a: string, b: string): number { } export default { makeAnagram }; +export { makeAnagram }; diff --git a/src/hackerrank/interview_preparation_kit/string_manipulation/sherlock_and_valid_string.ts b/src/hackerrank/interview_preparation_kit/string_manipulation/sherlock_and_valid_string.ts index 010280c0..e5dec697 100644 --- a/src/hackerrank/interview_preparation_kit/string_manipulation/sherlock_and_valid_string.ts +++ b/src/hackerrank/interview_preparation_kit/string_manipulation/sherlock_and_valid_string.ts @@ -5,7 +5,7 @@ const __YES__ = 'YES'; const __NO__ = 'NO'; -export function isValidCompute(s: string): boolean { +function isValidCompute(s: string): boolean { if (s.length <= 1) { return true; } @@ -48,8 +48,9 @@ export function isValidCompute(s: string): boolean { return false; } -export function isValid(s: string): string { +function isValid(s: string): string { return isValidCompute(s) ? __YES__ : __NO__; } export default { isValid }; +export { isValid }; diff --git a/src/hackerrank/lib/BigIntMath.ts b/src/hackerrank/lib/BigIntMath.ts index 45e410e8..290605ec 100644 --- a/src/hackerrank/lib/BigIntMath.ts +++ b/src/hackerrank/lib/BigIntMath.ts @@ -1,6 +1,6 @@ /* istanbul ignore file */ -export class BigIntMath { +class BigIntMath { static max(...values: bigint[]): bigint | null { if (values.length === 0) { return null; @@ -79,3 +79,4 @@ export class BigIntMath { } export default { BigIntMath }; +export { BigIntMath }; diff --git a/src/hackerrank/lib/Node.ts b/src/hackerrank/lib/Node.ts index 063a4ef9..fffffee0 100644 --- a/src/hackerrank/lib/Node.ts +++ b/src/hackerrank/lib/Node.ts @@ -1,6 +1,6 @@ /* istanbul ignore file */ -export class Node { +class Node { left: Node | null; right: Node | null; @@ -15,3 +15,4 @@ export class Node { } export default { Node }; +export { Node }; diff --git a/src/hackerrank/projecteuler/euler001.ts b/src/hackerrank/projecteuler/euler001.ts index c5cbea0a..ae6e073e 100644 --- a/src/hackerrank/projecteuler/euler001.ts +++ b/src/hackerrank/projecteuler/euler001.ts @@ -3,12 +3,12 @@ */ // Function to return gcd of a and b -export function gcd(a: number, b: number): number { +function gcd(a: number, b: number): number { if (a === 0) return b; return gcd(b % a, a); } -export function sumAp(n: number, d: number): number { +function sumAp(n: number, d: number): number { // Number of terms const _n = Math.floor(n / d); @@ -16,10 +16,13 @@ export function sumAp(n: number, d: number): number { } // Function to find the sum of all multiples of a and b below n -export function euler001(a: number, b: number, n: number): number { +function euler001(a: number, b: number, n: number): number { // Since, we need the sum of multiples less than N const _n = n - 1; const lcm = Math.floor((a * b) / gcd(a, b)); return sumAp(_n, a) + sumAp(_n, b) - sumAp(_n, lcm); } + +export default { euler001 }; +export { euler001 }; diff --git a/src/hackerrank/projecteuler/euler002.ts b/src/hackerrank/projecteuler/euler002.ts index 91c07ab0..35a6e851 100644 --- a/src/hackerrank/projecteuler/euler002.ts +++ b/src/hackerrank/projecteuler/euler002.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/projecteuler/euler002.md]] */ -export function fiboEvenSum(n: bigint): bigint { +function fiboEvenSum(n: bigint): bigint { let fibo1 = 1n; let fibo2 = 1n; let total = 0n; @@ -20,8 +20,9 @@ export function fiboEvenSum(n: bigint): bigint { return total; } -export function euler002(n: number): bigint { +function euler002(n: number): bigint { return fiboEvenSum(BigInt(n)); } export default { euler002 }; +export { euler002 }; diff --git a/src/hackerrank/projecteuler/euler003.ts b/src/hackerrank/projecteuler/euler003.ts index 01ce202f..538cfc45 100644 --- a/src/hackerrank/projecteuler/euler003.ts +++ b/src/hackerrank/projecteuler/euler003.ts @@ -4,7 +4,7 @@ import { BigIntMath } from '../lib/BigIntMath'; -export function primeFactor(n: bigint): bigint { +function primeFactor(n: bigint): bigint { if (n < 2) { throw new Error('n must be greater than 2'); } @@ -26,8 +26,9 @@ export function primeFactor(n: bigint): bigint { return maxPrimeFactor; } -export function euler003(n: number): bigint { +function euler003(n: number): bigint { return primeFactor(BigInt(n)); } export default { euler003 }; +export { euler003 }; diff --git a/src/hackerrank/warmup/aVeryBigSum.ts b/src/hackerrank/warmup/aVeryBigSum.ts index 7dff56f9..b447845a 100644 --- a/src/hackerrank/warmup/aVeryBigSum.ts +++ b/src/hackerrank/warmup/aVeryBigSum.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/aVeryBigSum.md]] */ -export function aVeryBigSum(ar: number[]): number { +function aVeryBigSum(ar: number[]): number { let result = 0; for (const num of ar) { @@ -13,3 +13,4 @@ export function aVeryBigSum(ar: number[]): number { } export default { aVeryBigSum }; +export { aVeryBigSum }; diff --git a/src/hackerrank/warmup/birthdayCakeCandles.ts b/src/hackerrank/warmup/birthdayCakeCandles.ts index d91daf2e..0b5b032d 100644 --- a/src/hackerrank/warmup/birthdayCakeCandles.ts +++ b/src/hackerrank/warmup/birthdayCakeCandles.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/birthdayCakeCandles.md]] */ -export function birthdayCakeCandles(ar: number[]): number { +function birthdayCakeCandles(ar: number[]): number { if (ar.length === 0) { throw new Error('Empty input'); } @@ -23,3 +23,4 @@ export function birthdayCakeCandles(ar: number[]): number { } export default { birthdayCakeCandles }; +export { birthdayCakeCandles }; diff --git a/src/hackerrank/warmup/compareTriplets.ts b/src/hackerrank/warmup/compareTriplets.ts index ac6df4de..99971411 100644 --- a/src/hackerrank/warmup/compareTriplets.ts +++ b/src/hackerrank/warmup/compareTriplets.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/compareTriplets.md]] */ -export function compareTriplets(a: number[], b: number[]): number[] { +function compareTriplets(a: number[], b: number[]): number[] { const awards = [0, 0]; if (a.length !== b.length) { @@ -21,3 +21,4 @@ export function compareTriplets(a: number[], b: number[]): number[] { } export default { compareTriplets }; +export { compareTriplets }; diff --git a/src/hackerrank/warmup/diagonalDifference.ts b/src/hackerrank/warmup/diagonalDifference.ts index 2f0c6579..98f9996c 100644 --- a/src/hackerrank/warmup/diagonalDifference.ts +++ b/src/hackerrank/warmup/diagonalDifference.ts @@ -4,7 +4,7 @@ import { logger as console } from '../../logger'; -export function diagonalDifference(arr: number[][]): number { +function diagonalDifference(arr: number[][]): number { let diag1 = 0; let diag2 = 0; const last = arr.length - 1; @@ -24,3 +24,4 @@ export function diagonalDifference(arr: number[][]): number { } export default { diagonalDifference }; +export { diagonalDifference }; diff --git a/src/hackerrank/warmup/miniMaxSum.ts b/src/hackerrank/warmup/miniMaxSum.ts index f5be1eff..40ea08ec 100644 --- a/src/hackerrank/warmup/miniMaxSum.ts +++ b/src/hackerrank/warmup/miniMaxSum.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/miniMaxSum.md]] */ -export function miniMaxSum(arr: number[]): string { +function miniMaxSum(arr: number[]): string { if (arr.length === 0) { throw new Error('Empty input'); } @@ -27,3 +27,4 @@ export function miniMaxSum(arr: number[]): string { } export default { miniMaxSum }; +export { miniMaxSum }; diff --git a/src/hackerrank/warmup/plusMinus.ts b/src/hackerrank/warmup/plusMinus.ts index b64f1f97..ef183244 100644 --- a/src/hackerrank/warmup/plusMinus.ts +++ b/src/hackerrank/warmup/plusMinus.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/plusMinus.md]] */ -export function plusMinus(arr: number[]): string { +function plusMinus(arr: number[]): string { let positives = 0; let negatives = 0; let zeros = 0; @@ -27,3 +27,4 @@ export function plusMinus(arr: number[]): string { } export default { plusMinus }; +export { plusMinus }; diff --git a/src/hackerrank/warmup/simpleArraySum.ts b/src/hackerrank/warmup/simpleArraySum.ts index 311e57a3..9aa0a00a 100644 --- a/src/hackerrank/warmup/simpleArraySum.ts +++ b/src/hackerrank/warmup/simpleArraySum.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/simpleArraySum.md]] */ -export function simpleArraySum(ar: number[]): number { +function simpleArraySum(ar: number[]): number { let acum = 0; for (const num of ar) { @@ -13,3 +13,4 @@ export function simpleArraySum(ar: number[]): number { } export default { simpleArraySum }; +export { simpleArraySum }; diff --git a/src/hackerrank/warmup/solveMeFirst.ts b/src/hackerrank/warmup/solveMeFirst.ts index 91be3553..70a91193 100644 --- a/src/hackerrank/warmup/solveMeFirst.ts +++ b/src/hackerrank/warmup/solveMeFirst.ts @@ -4,7 +4,7 @@ const __RADIX__ = 10; -export function solveMeFirst(inputLines: string[]): number { +function solveMeFirst(inputLines: string[]): number { let result = 0; inputLines.forEach((v) => { @@ -15,3 +15,4 @@ export function solveMeFirst(inputLines: string[]): number { } export default { solveMeFirst }; +export { solveMeFirst }; diff --git a/src/hackerrank/warmup/staircase.ts b/src/hackerrank/warmup/staircase.ts index 58a0670a..5e57c863 100644 --- a/src/hackerrank/warmup/staircase.ts +++ b/src/hackerrank/warmup/staircase.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/staircase.md]] */ -export function staircase(n: number): string { +function staircase(n: number): string { const result: string[] = []; for (let i = 1; i <= n; i++) { @@ -23,3 +23,4 @@ export function staircase(n: number): string { } export default { staircase }; +export { staircase }; diff --git a/src/hackerrank/warmup/timeConversion.ts b/src/hackerrank/warmup/timeConversion.ts index baf53c4e..66df9a46 100644 --- a/src/hackerrank/warmup/timeConversion.ts +++ b/src/hackerrank/warmup/timeConversion.ts @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/warmup/timeConversion.md]] */ -export function timeConversion(s: string): string { +function timeConversion(s: string): string { let meridian = s.substring(s.length - 2, s.length); meridian = meridian.toLowerCase(); @@ -26,3 +26,4 @@ export function timeConversion(s: string): string { } export default { timeConversion }; +export { timeConversion }; diff --git a/src/hello_world.ts b/src/hello_world.ts index 23e40d9e..d8a16d00 100644 --- a/src/hello_world.ts +++ b/src/hello_world.ts @@ -1,7 +1,8 @@ const greeting = 'world'; -export function hello(world: string = greeting): string { +function hello(world: string = greeting): string { return `Hello ${world}!`; } export default { hello }; +export { hello }; diff --git a/src/problem0000.ts b/src/problem0000.ts index 2ec0f459..03a39ecf 100644 --- a/src/problem0000.ts +++ b/src/problem0000.ts @@ -7,7 +7,7 @@ import { logger as console } from './logger'; -export function problem0000(): null { +function problem0000(): null { const result = null; console.info(`result ${String(result)}`); @@ -16,3 +16,4 @@ export function problem0000(): null { } export default { problem0000 }; +export { problem0000 }; diff --git a/src/projecteuler/problem0002.ts b/src/projecteuler/problem0002.ts index 98fcb3fc..8fb702a3 100644 --- a/src/projecteuler/problem0002.ts +++ b/src/projecteuler/problem0002.ts @@ -4,7 +4,7 @@ import { logger as console } from '../logger'; -export function problem0002(_top: number): number { +function problem0002(_top: number): number { let i = 0; let last1 = 1; let last2 = 0; @@ -31,3 +31,4 @@ export function problem0002(_top: number): number { } export default { problem0002 }; +export { problem0002 }; diff --git a/src/projecteuler/problem0017.ts b/src/projecteuler/problem0017.ts index 18a4364d..7a4bf0ce 100644 --- a/src/projecteuler/problem0017.ts +++ b/src/projecteuler/problem0017.ts @@ -5,7 +5,7 @@ import { logger as console } from '../logger'; import { numberToWord } from './helpers'; -export default function problem0017(init: number, last: number): number { +function problem0017(init: number, last: number): number { let replaced; let word; let acum = 0; @@ -24,4 +24,5 @@ export default function problem0017(init: number, last: number): number { return acum; } +export default { problem0017 }; export { problem0017 }; diff --git a/src/projecteuler/problem0018.ts b/src/projecteuler/problem0018.ts index 7491f751..8dc70e8c 100644 --- a/src/projecteuler/problem0018.ts +++ b/src/projecteuler/problem0018.ts @@ -8,7 +8,7 @@ import { logger as console } from '../logger'; const rootCoordinateI = 0; const rootCoordinateJ = 0; -export function problem0018(_triangle: number[][]): number { +function problem0018(_triangle: number[][]): number { console.debug(`_triangle: ${_triangle.toString()}`); console.debug( `_triangle: ${JSON.stringify( @@ -38,3 +38,4 @@ export function problem0018(_triangle: number[][]): number { } export default { problem0018 }; +export { problem0018 }; diff --git a/src/projecteuler/problem0019.ts b/src/projecteuler/problem0019.ts index 4ea1f299..c7e0191d 100644 --- a/src/projecteuler/problem0019.ts +++ b/src/projecteuler/problem0019.ts @@ -5,7 +5,7 @@ import { logger as console } from '../logger'; import { daysInMonth, __SUNDAY__ } from '../constants'; -export function problem0019( +function problem0019( _dayOfWeek = __SUNDAY__, _sinceYear = 1901, _untilYear = 2000 @@ -35,3 +35,4 @@ export function problem0019( } export default { problem0019 }; +export { problem0019 }; diff --git a/src/projecteuler/problem0020.ts b/src/projecteuler/problem0020.ts index e8b28637..35ecc257 100644 --- a/src/projecteuler/problem0020.ts +++ b/src/projecteuler/problem0020.ts @@ -13,7 +13,7 @@ import { logger as console } from '../logger'; import { bigFactorial, bigSumMany } from './helpers'; -export function problem0020(_limit: number): string { +function problem0020(_limit: number): string { const strFactorial = bigFactorial(_limit); console.log(`Factorial of ${_limit}!: ${strFactorial}`); @@ -26,3 +26,4 @@ export function problem0020(_limit: number): string { } export default { problem0020 }; +export { problem0020 }; diff --git a/src/projecteuler/problem0021.ts b/src/projecteuler/problem0021.ts index d107afc0..8ce69bba 100644 --- a/src/projecteuler/problem0021.ts +++ b/src/projecteuler/problem0021.ts @@ -19,7 +19,7 @@ import { logger as console } from '../logger'; import { properDivisors, bigSumMany } from './helpers'; -export function problem0021(_start: number, _limit: number): string { +function problem0021(_start: number, _limit: number): string { const properDivisorsOf: number[] = []; for (let i = _start; i <= _limit; i++) { @@ -47,3 +47,4 @@ export function problem0021(_start: number, _limit: number): string { } export default { problem0021 }; +export { problem0021 }; diff --git a/src/projecteuler/problem0022.ts b/src/projecteuler/problem0022.ts index f1fca53b..a08dee06 100644 --- a/src/projecteuler/problem0022.ts +++ b/src/projecteuler/problem0022.ts @@ -5,7 +5,7 @@ import { logger as console } from '../logger'; import { wordScore } from './helpers/wordScore'; -export function problem0022(listOfNames: string[]): number { +function problem0022(listOfNames: string[]): number { listOfNames.sort((a, b) => a.localeCompare(b)); let result = 0; @@ -21,3 +21,4 @@ export function problem0022(listOfNames: string[]): number { } export default { problem0022 }; +export { problem0022 }; diff --git a/src/projecteuler/problem0023.ts b/src/projecteuler/problem0023.ts index 10e7a304..f28a4418 100644 --- a/src/projecteuler/problem0023.ts +++ b/src/projecteuler/problem0023.ts @@ -5,7 +5,7 @@ import { logger as console } from '../logger'; import { abundance, sum, ___DIVISORS_ABUNDANCE___ } from './helpers'; -export function problem0023(_underLimit: number, _superLimit: number): number { +function problem0023(_underLimit: number, _superLimit: number): number { const abundantNumberList = []; // Produce a list of abundant numbers below limit @@ -61,3 +61,4 @@ export function problem0023(_underLimit: number, _superLimit: number): number { } export default { problem0023 }; +export { problem0023 }; diff --git a/src/projecteuler/problem0024.ts b/src/projecteuler/problem0024.ts index 3d0671d8..0c2a0ad4 100644 --- a/src/projecteuler/problem0024.ts +++ b/src/projecteuler/problem0024.ts @@ -34,7 +34,7 @@ const permute = (symbols: string, target: number): string => { return answer; }; -export function problem0024( +function problem0024( inputElements: string, inputPermutationToFind: number ): string { @@ -46,3 +46,4 @@ export function problem0024( } export default { problem0024 }; +export { problem0024 }; diff --git a/src/projecteuler/problem0025.ts b/src/projecteuler/problem0025.ts index cd0aaa28..e8796e82 100644 --- a/src/projecteuler/problem0025.ts +++ b/src/projecteuler/problem0025.ts @@ -5,7 +5,7 @@ import { logger as console } from '../logger'; import { bigNum, bigSum, bigNumToString } from './helpers'; -export function problem0025(_top: number): number { +function problem0025(_top: number): number { let last1 = bigNum('1'); let last2 = bigNum('1'); let counter = 2; @@ -26,3 +26,4 @@ export function problem0025(_top: number): number { } export default { problem0025 }; +export { problem0025 };