Sha256: fa02f775e4463df52396acf9f275fabd9e644b0e7242f3bf83a4823def7a3167

Contents?: true

Size: 941 Bytes

Versions: 68

Compression:

Stored size: 941 Bytes

Contents

class Matrix {
    private description: string
    rows: number[][] = new Array<number[]>()
    columns: number[][] = new Array<number[]>()

    constructor(description: string) {
        this.description = description
        this.parseMatrix()
    }

    private parseMatrix(): void {
        this.parseRows()
        this.parseColumns()
    }

    private parseRows(): void {
        this.rows = this.description.split('\n').map((row) => {
            return row.split(' ').map((char) => {
                return parseInt(char, 10)
            })
        })
    }

    private parseColumns(): void {
        const rowsLength = this.rows.length
        const columnsLength = this.rows[0].length
        for (let i = 0; i < columnsLength; i++) {
            this.columns.push([])
            for (let j = 0; j < rowsLength; j++) {
                this.columns[i].push(this.rows[j][i])
            }
        }
    }
}

export default Matrix

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.179 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.178 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.177 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.176 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.175 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.174 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.173 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.172 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.171 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.170 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.169 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.167 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.166 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.165 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.164 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.163 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.162 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.161 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.160 tracks/typescript/exercises/matrix/matrix.example.ts