From ecc8e130ce04bc929b60a869bc14b46a0e14d7cd Mon Sep 17 00:00:00 2001 From: Bohdan Diatliuk Date: Wed, 12 Nov 2025 10:21:46 +0200 Subject: [PATCH 1/6] solution --- src/splitInteger.js | 2 +- src/splitInteger.test.js | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/splitInteger.js b/src/splitInteger.js index d3da7485..0b646141 100644 --- a/src/splitInteger.js +++ b/src/splitInteger.js @@ -1,4 +1,4 @@ -'use strict'; +"use strict"; /** * @param {number} value diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index a610317d..299221a2 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -1,21 +1,26 @@ -'use strict'; +"use strict"; -const splitInteger = require('./splitInteger'); +const splitInteger = require("./splitInteger"); test(`should split a number into equal parts if a value is divisible by a numberOfParts`, () => { - + expect(splitInteger(6, 3)).toEqual([2, 2, 2]); + expect(splitInteger(10, 5)).toEqual([2, 2, 2, 2, 2]); + expect(splitInteger(8, 4)).toEqual([2, 2, 2, 2]); }); test(`should return a part equals to a value when splitting into 1 part`, () => { - + expect(splitInteger(10, 1)).toEqual([10]); }); -test('should sort parts ascending if they are not equal', () => { - +test("should sort parts ascending if they are not equal", () => { + expect(splitInteger(10, 3)).toEqual([3, 3, 4]); + expect(splitInteger(11, 4)).toEqual([2, 3, 3, 3]); }); -test('should add zeros if value < numberOfParts', () => { - +test("should add zeros if value < numberOfParts", () => { + expect(splitInteger(3, 5)).toEqual([0, 0, 1, 1, 1]); + expect(splitInteger(2, 4)).toEqual([0, 0, 1, 1]); + expect(splitInteger(1, 3)).toEqual([0, 0, 1]); }); From e6f50d5df361c9262c129cf7f9c67acdf0cd5869 Mon Sep 17 00:00:00 2001 From: Bohdan Diatliuk Date: Wed, 12 Nov 2025 11:38:36 +0200 Subject: [PATCH 2/6] fixed --- src/splitInteger.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 299221a2..6a483f07 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -24,3 +24,19 @@ test("should add zeros if value < numberOfParts", () => { expect(splitInteger(2, 4)).toEqual([0, 0, 1, 1]); expect(splitInteger(1, 3)).toEqual([0, 0, 1]); }); + +test("splitInteger(8, 1) should return [8]", () => { + expect(splitInteger(8, 1)).toEqual([8]); +}); + +test("splitInteger(6, 2) should return [3, 3]", () => { + expect(splitInteger(6, 2)).toEqual([3, 3]); +}); + +test("splitInteger(17, 4) should return [4, 4, 4, 5]", () => { + expect(splitInteger(17, 4)).toEqual([4, 4, 4, 5]); +}); + +test("splitInteger(8, 1) should return [8]", () => { + expect(splitInteger(8, 1)).toEqual([8]); +}); From 14079db5e4c69d53288d20fec329b1779944b7fc Mon Sep 17 00:00:00 2001 From: Bohdan Diatliuk Date: Wed, 12 Nov 2025 11:40:00 +0200 Subject: [PATCH 3/6] modified last test --- src/splitInteger.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 6a483f07..ca9e9a4b 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -38,5 +38,5 @@ test("splitInteger(17, 4) should return [4, 4, 4, 5]", () => { }); test("splitInteger(8, 1) should return [8]", () => { - expect(splitInteger(8, 1)).toEqual([8]); + expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]); }); From 56685b904d0ad9426b61d2294e8ad1008079e151 Mon Sep 17 00:00:00 2001 From: Bohdan Diatliuk Date: Wed, 12 Nov 2025 11:40:26 +0200 Subject: [PATCH 4/6] m --- src/splitInteger.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index ca9e9a4b..12438681 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -37,6 +37,6 @@ test("splitInteger(17, 4) should return [4, 4, 4, 5]", () => { expect(splitInteger(17, 4)).toEqual([4, 4, 4, 5]); }); -test("splitInteger(8, 1) should return [8]", () => { +test("splitInteger(32, 6) should return [5, 5, 5, 5, 6, 6]", () => { expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]); }); From 472b2ce0388edfac27be5a019b89afea657c8570 Mon Sep 17 00:00:00 2001 From: Bohdan Diatliuk Date: Wed, 12 Nov 2025 11:45:20 +0200 Subject: [PATCH 5/6] fix --- src/splitInteger.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 12438681..d6bc9ee3 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -40,3 +40,4 @@ test("splitInteger(17, 4) should return [4, 4, 4, 5]", () => { test("splitInteger(32, 6) should return [5, 5, 5, 5, 6, 6]", () => { expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]); }); + From a2d1cf48b5765c3177b112e6bd4766ce55d10b8b Mon Sep 17 00:00:00 2001 From: Bohdan Diatliuk Date: Wed, 12 Nov 2025 12:00:18 +0200 Subject: [PATCH 6/6] fixedd --- src/splitInteger.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index d6bc9ee3..3714cb57 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -38,6 +38,6 @@ test("splitInteger(17, 4) should return [4, 4, 4, 5]", () => { }); test("splitInteger(32, 6) should return [5, 5, 5, 5, 6, 6]", () => { + expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]); }); -