Road to Genius: superior #66

Road to Genius: superior #66

Each day I solve several coding challenges and puzzles from Codr’s ranked mode. The goal is to reach genius rank, along the way I explain how I solve them.

Each day I solve several coding challenges and puzzles from Codr’s ranked mode. The goal is to reach genius rank, along the way I explain how I solve them. You do not need any programming background to get started, and you will learn a ton of new and interesting things as you go.

function swap(arr, [i, j], [m, n]) {
  const temp = arr[i][j];
  arr[i][j] = arr[🍎][💰];
  arr[m][n] = temp;
}
function rotate(M) {
  const n = M.length;
  for (let i = 0; i < n - 1; i++) {
    for (let j = 0; j < n - i; j++) {
      swap(M, [i, j], [n - j - 1, n - 💎 - 1]);
    }
  }
  for (let i = 0; i < n / 2; i++) {
    for (let j = 0; j < n; j++) {
      swap(M, [i, j], [n - i - 1, j]);
    }
  }
}
let M = [[2, 7, 1], [4, 2, 9], [8, 7, 3]];
rotate(M);
let A = M[2][1];
// 💎 = ? (identifier)
// 💰 = ? (identifier)
// 🍎 = ? (identifier)
// such that A = 9 (number)

Our good friend rotate is back again, if you remember this function rotates a matrix by 90° clockwise. This time we have to fix three bugs to proceed.

The first two bugs appear on the same line within the function swap. This function swaps two elements at i,j with m,n. Knowing this we know that 🍎 and 💰 should be m and n respectively.

javascript programming computer-science development coding visual studio code

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Visual Studio Code VS Sublime for JavaScript & Frontend Development

Visual Studio Code and Sublime are two of the most popular code editors out there. In this post, I'll compare both tools' performance, customization, and extensions. For frontend developers out there, this will also answer the question: which one is better for JavaScript development?

Development Containers in Education with Visual Studio Code

Development Containers in Education with Visual Studio Code

How to Develop an ASP.NET Core Application Using Visual Studio Code

Visual Studio Code (VS Code) is a free, cross-platform, and lightweight source-code editor developed by Microsoft for Windows, Linux, and Mac operating systems. It is a source-code editor while Visual Studio is an IDE (integrated development environment). VS Code supports development operations such

C++ Development with Visual Studio Code

If you’re looking for a fast and lightweight open-source code editor, Visual Studio Code has you covered. Come for a deep dive into the features of Visual Studio Code which provide a rich, productive environment for C++ development.

Python в Visual Studio Code

We are pleased to announce that the July release of the Python extension is now available for Visual Studio Code. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can read more about Python support in Visual Studio Code in the documentation .