export class Matrix {
  private _rows: number[][];
  private _columns: number[][];

  constructor(matrix: string) {
    this._rows = matrix
      .split("\n")
      .filter(Boolean)
      .map((row) =>
        row
          .split(" ")
          .filter(Boolean)
          .map((v) => parseInt(v, 10))
      );

    this._columns = this.rows[0].map((_, i) => this.rows.map((row) => row[i]));
  }

  get rows(): number[][] {
    return this._rows;
  }

  get columns(): number[][] {
    return this._columns;
  }
}
