awesome

Finished
88 * @param {string} numberString
99 */
1010 constructor(numberString) {
11 throw new Error('Remove this line and implement the function');
11 // Edge Case: Series cannot be empty
12 if (numberString === '') {
13 throw new Error('series cannot be empty');
14 }
15
16 this.digits = numberString.split('').map(Number);
17 this.series = numberString;
1218 }
1319
1420 /**
1622 * @returns {number[][]}
1723 */
1824 slices(sliceSize) {
19 throw new Error('Remove this line and implement the function');
25 // Edge Case: Slice length cannot be negative
26 if (sliceSize < 0) {
27 throw new Error('slice length cannot be negative');
28 }
29
30 // Edge Case: Slice length cannot be zero
31 if (sliceSize === 0) {
32 throw new Error('slice length cannot be zero');
33 }
34
35 // Edge Case: Slice length cannot be greater than series length
36 if (sliceSize > this.series.length) {
37 throw new Error('slice length cannot be greater than series length');
38 }
39
40 const result = [];
41
42 // Use sliding window to extract all contiguous substrings
43 for (let i = 0; i <= this.digits.length - sliceSize; i++) {
44 result.push(this.digits.slice(i, i + sliceSize));
45 }
46
47 return result;
2048 }
2149}
50
51// Handled Edge Cases: Series cannot be empty, Slice length cannot be negative, Slice length cannot be zero, Slice length cannot be greater than series length
Test NameStatus
slices of one from one
Pass
slices of one from two
Pass
slices of two
Pass
slices of two overlap
Pass
slices can include duplicates
Pass
slices of long series
Pass
slice length is too large
Pass
slice length is way too large
Pass
slice length cannot be zero
Pass
slice length cannot be negative
Pass
empty series is invalid
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.