freeCodeCamp/curriculum/challenges/russian/08-coding-interview-prep/rosetta-code/identity-matrix.russian.md

2.6 KiB
Raw Blame History

title id challengeType videoUrl localeTitle
Identity matrix 5a23c84252665b21eecc7eb1 5 Единичная матрица

Description

Единичная матрица является квадратной матрицей размера \ (n \ times n \), где диагональные элементы - все 1 s (одни), а все остальные элементы - все 0 s (нули). \ begin {bmatrix} 1 & 0 & 0 \ cr 0 & 1 & 0 \ cr 0 & 0 & 1 \ cr \ end {bmatrix} Напишите функцию, которая принимает число «n» в качестве параметра и возвращает единичную матрицу порядок nx n.

Instructions

Tests

tests:
  - text: <code>idMatrix</code> должна быть функцией.
    testString: 'assert(typeof idMatrix=="function","<code>idMatrix</code> should be a function.");'
  - text: <code>idMatrix(1)</code> должен возвращать массив.
    testString: 'assert(Array.isArray(idMatrix(1)),"<code>idMatrix(1)</code> should return an array.");'
  - text: '<code>idMatrix(1)</code> должен возвращать <code>&quot;+JSON.stringify(results[0])+&quot;</code> .'
    testString: 'assert.deepEqual(idMatrix(1),results[0],"<code>idMatrix(1)</code> should return <code>"+JSON.stringify(results[0])+"</code>.");'
  - text: '<code>idMatrix(2)</code> должен возвращать <code>&quot;+JSON.stringify(results[1])+&quot;</code> .'
    testString: 'assert.deepEqual(idMatrix(2),results[1],"<code>idMatrix(2)</code> should return <code>"+JSON.stringify(results[1])+"</code>.");'
  - text: '<code>idMatrix(3)</code> должен возвращать <code>&quot;+JSON.stringify(results[2])+&quot;</code> .'
    testString: 'assert.deepEqual(idMatrix(3),results[2],"<code>idMatrix(3)</code> should return <code>"+JSON.stringify(results[2])+"</code>.");'
  - text: '<code>idMatrix(4)</code> должен возвращать <code>&quot;+JSON.stringify(results[3])+&quot;</code> .'
    testString: 'assert.deepEqual(idMatrix(4),results[3],"<code>idMatrix(4)</code> should return <code>"+JSON.stringify(results[3])+"</code>.");'

Challenge Seed

function idMatrix (n) {
  // Good luck!
}

After Test

console.info('after the test');

Solution

// solution required