Series

in #itayesterday

export class Series { series: string; constructor(series: string) { this.series = series; if(this.series.length === 0) throw new Error('series cannot be empty'); } slices(sliceLength: number): number[][] { let res: number[][] = []; if(sliceLength < 0) throw new Error('slice length cannot be negative'); if(sliceLength === 0) throw new Error('slice length cannot be zero'); if(this.series.length < sliceLength) throw new Error('slice length cannot be greater than series length'); for(let i=0; i<this.series.length-sliceLength+1; i++){ res.push(this.series.slice(i,i+sliceLength).split('').map(Number)); } return res; } }