Skip to content

Commit 3c35df8

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] projecteuler exercises.
* standarized interface.
1 parent bc1f552 commit 3c35df8

File tree

9 files changed

+18
-9
lines changed

9 files changed

+18
-9
lines changed

src/projecteuler/problem0017.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { logger as console } from '../logger.js';
66
import { numberToWord } from './helpers/index.js';
77

8-
export default function problem0017(init, last) {
8+
function problem0017(init, last) {
99
let replaced;
1010
let word;
1111
let acum = 0;
@@ -24,4 +24,5 @@ export default function problem0017(init, last) {
2424
return acum;
2525
}
2626

27+
export default { problem0017 };
2728
export { problem0017 };

src/projecteuler/problem0018.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { logger as console } from '../logger.js';
77
const rootCoordinateI = 0;
88
const rootCoordinateJ = 0;
99

10-
export function problem0018(_triangle) {
10+
function problem0018(_triangle) {
1111
console.debug('_triangle', _triangle);
1212
console.debug(
1313
'_triangle',
@@ -33,3 +33,4 @@ export function problem0018(_triangle) {
3333
}
3434

3535
export default { problem0018 };
36+
export { problem0018 };

src/projecteuler/problem0019.js

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

77
const __FEBRUARY__KEY__ = 'FEBRUARY';
88

9-
export function problem0019(
9+
function problem0019(
1010
_dayOfWeek = __SUNDAY__,
1111
_sinceYear = 1901,
1212
_untilYear = 2000
@@ -44,3 +44,4 @@ export function problem0019(
4444
}
4545

4646
export default { problem0019 };
47+
export { problem0019 };

src/projecteuler/problem0020.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { logger as console } from '../logger.js';
1313

1414
import { bigFactorial, bigSumMany } from './helpers/bigNumbers.js';
1515

16-
export function problem0020(_limit) {
16+
function problem0020(_limit) {
1717
const strFactorial = bigFactorial(_limit);
1818

1919
console.log(`Factorial of ${_limit}!:`, strFactorial);
@@ -24,3 +24,4 @@ export function problem0020(_limit) {
2424
}
2525

2626
export default { problem0020 };
27+
export { problem0020 };

src/projecteuler/problem0021.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { logger as console } from '../logger.js';
1919

2020
import { divisors, bigSumMany } from './helpers/index.js';
2121

22-
export function problem0021(_start, _limit) {
22+
function problem0021(_start, _limit) {
2323
const data = {};
2424

2525
for (let i = _start; i <= _limit; i++) {
@@ -49,3 +49,4 @@ export function problem0021(_start, _limit) {
4949
}
5050

5151
export default { problem0021 };
52+
export { problem0021 };

src/projecteuler/problem0022.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { logger as console } from '../logger.js';
66
import { wordScore } from './helpers/wordScore.js';
77

8-
export function problem0022(listOfNames) {
8+
function problem0022(listOfNames) {
99
listOfNames.sort((a, b) => a.localeCompare(b));
1010

1111
let result = 0;
@@ -21,3 +21,4 @@ export function problem0022(listOfNames) {
2121
}
2222

2323
export default { problem0022 };
24+
export { problem0022 };

src/projecteuler/problem0023.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { logger as console } from '../logger.js';
66
import { abundance, ___DIVISORS_ABUNDANT___, sum } from './helpers/index.js';
77

8-
export function problem0023(_underLimit, _superLimit) {
8+
function problem0023(_underLimit, _superLimit) {
99
const allNumsList = [];
1010
const abundantNumberList = [];
1111

@@ -64,3 +64,4 @@ export function problem0023(_underLimit, _superLimit) {
6464
}
6565

6666
export default { problem0023 };
67+
export { problem0023 };

src/projecteuler/problem0024.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const permute = (symbols, target) => {
3434
return answer;
3535
};
3636

37-
export function problem0024(inputElements, inputPermutationToFind) {
37+
function problem0024(inputElements, inputPermutationToFind) {
3838
const permutationFound = permute(inputElements, inputPermutationToFind);
3939

4040
console.debug(`result ${String(permutationFound)}`);
@@ -43,3 +43,4 @@ export function problem0024(inputElements, inputPermutationToFind) {
4343
}
4444

4545
export default { problem0024 };
46+
export { problem0024 };

src/projecteuler/problem0025.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { logger as console } from '../logger.js';
66
import { bigNum, bigSum, bigNumToString } from './helpers/index.js';
77

8-
export function problem0025(_top) {
8+
function problem0025(_top) {
99
let last1 = bigNum('1');
1010
let last2 = bigNum('1');
1111
let counter = 2;
@@ -26,3 +26,4 @@ export function problem0025(_top) {
2626
}
2727

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

0 commit comments

Comments
 (0)