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.159 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.158 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.157 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.156 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.155 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.154 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.153 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.152 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.151 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.150 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.149 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.148 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.147 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.146 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.145 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.144 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.143 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.142 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.141 tracks/typescript/exercises/matrix/matrix.example.ts
trackler-2.2.1.140 tracks/typescript/exercises/matrix/matrix.example.ts