Advertisement
PadmaJS

Untitled

Feb 2nd, 2021
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. class Matrix {
  2. constructor(string) {
  3. this.matrix = string.split("\n").map((line) => line.split(" ").map((char) => Number(char)));
  4. }
  5.  
  6. get rows() {
  7. return this.matrix;
  8. }
  9.  
  10. get columns() {
  11. return this.matrix[0].map((column, index) => this.matrix.map(row => row[index]));
  12. }
  13.  
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement