Finished
55
66export class Series {
77 constructor(series) {
8 throw new Error('Remove this line and implement the function');
8 // Edge Case: empty input string
9 if (series === '') {
10 throw new Error('series cannot be empty');
11 }
12 this.series = series;
913 }
1014
1115 slices(sliceLength) {
12 throw new Error('Remove this line and implement the function');
16 // Edge Case: slice length is zero
17 if (sliceLength === 0) {
18 throw new Error('slice length cannot be zero');
19 }
20
21 // Edge Case: slice length is negative
22 if (sliceLength < 0) {
23 throw new Error('slice length cannot be negative');
24 }
25
26 // Edge Case: slice length greater than series length
27 if (sliceLength > this.series.length) {
28 throw new Error('slice length cannot be greater than series length');
29 }
30
31 const result = [];
32
33 // Edge Case: single character input string with slice length of 1
34 if (this.series.length === 1 && sliceLength === 1) {
35 result.push([parseInt(this.series[0])]);
36 return result;
37 }
38
39 for (let i = 0; i <= this.series.length - sliceLength; i++) {
40 const slice = [];
41 for (let j = 0; j < sliceLength; j++) {
42 slice.push(parseInt(this.series[i + j]));
43 }
44 result.push(slice);
45 }
46
47 return result;
1348 }
1449}
50
51// Handled Edge Cases: empty input string, slice length is zero, slice length is negative, slice length greater than series length, single character input string with slice length of 1
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.