Skip to content

Commit f909e00

Browse files
committed
chore(deps): update dependencies
1 parent ae8e9fe commit f909e00

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

2022/challenge-04/solution.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,18 @@ const fitsInOneBoxAlt = boxes => {
2525
});
2626
};
2727

28-
export { fitsInOneBox, fitsInOneBoxAlt };
28+
const fitsInOneBoxSome = boxes => {
29+
const sortedBoxes = [...boxes].sort((firstBox, secondBox) => {
30+
return firstBox.l - secondBox.l;
31+
});
32+
33+
return !sortedBoxes.some((currentBox, index, sortedBoxesList) =>
34+
sortedBoxesList
35+
.slice(index + 1)
36+
.some(remainBox =>
37+
[remainBox.l > currentBox.l, remainBox.w > currentBox.w, remainBox.h > currentBox.h].includes(false)
38+
)
39+
);
40+
};
41+
42+
export { fitsInOneBox, fitsInOneBoxAlt, fitsInOneBoxSome };

2022/challenge-04/solution.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fitsInOneBox, fitsInOneBoxAlt } from './solution';
1+
import { fitsInOneBox, fitsInOneBoxAlt, fitsInOneBoxSome } from './solution';
22

33
describe('Challenge 04: Box inside a box and another...', () => {
44
describe('fitsInOneBox(...)', () => {
@@ -51,11 +51,13 @@ describe('Challenge 04: Box inside a box and another...', () => {
5151
it('#T should return a boolean', () => {
5252
expect(typeof fitsInOneBox([{ l: 1, w: 1, h: 1 }])).toBe('boolean');
5353
expect(typeof fitsInOneBoxAlt([{ l: 1, w: 1, h: 1 }])).toBe('boolean');
54+
expect(typeof fitsInOneBoxSome([{ l: 1, w: 1, h: 1 }])).toBe('boolean');
5455
});
5556

5657
it.each(testCases)('#$# $description', ({ args, expected }) => {
5758
expect(fitsInOneBox(...args)).toEqual(expected);
5859
expect(fitsInOneBoxAlt(...args)).toEqual(expected);
60+
expect(fitsInOneBoxSome(...args)).toEqual(expected);
5961
});
6062
});
6163
});

package-lock.json

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@babel/node": "^7.20.5",
3838
"@babel/preset-env": "^7.20.2",
3939
"babel-jest": "^29.3.1",
40-
"eslint": "^8.28.0",
40+
"eslint": "^8.29.0",
4141
"eslint-config-airbnb-base": "^15.0.0",
4242
"eslint-config-node": "^4.1.0",
4343
"eslint-config-prettier": "^8.5.0",
@@ -46,8 +46,8 @@
4646
"eslint-plugin-node": "^11.1.0",
4747
"eslint-plugin-prettier": "^4.2.1",
4848
"husky": "^8.0.2",
49-
"lint-staged": "^13.0.4",
50-
"prettier": "^2.8.0"
49+
"lint-staged": "^13.1.0",
50+
"prettier": "^2.8.1"
5151
},
5252
"dependencies": {
5353
"@jest/test-sequencer": "^29.3.1",

0 commit comments

Comments
 (0)