Skip to content

Commit

Permalink
[ 馃毀 WIP ] finished working the rotate matrix challenge (codinasion#5698)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Teklemariam <sarah.f.tsion@gmail.com>
Co-authored-by: Harsh Raj <harshraj8843@gmail.com>
Closes https://github.com/codinasion/program/issues/5453
  • Loading branch information
SarahTek committed Dec 17, 2022
1 parent 0a9565e commit 80877ae
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";

let N = 3;

function rotate90Clockwise(arr) {
for (let j = 0; j < N; j++) {
for (let i = N - 1; i >= 0; i--) {
process.stdout.write(arr[i][j] + " ");
}
console.log();
}
}

let arr = [
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
];

console.log("Initial matrix:");
for (let i = 0; i < N; i++) {
for (let j = 0; j < N; j++) {
process.stdout.write(arr[i][j] + " ");
}
console.log();
}

console.log("\nRotated matrix:");
rotate90Clockwise(arr);

0 comments on commit 80877ae

Please sign in to comment.