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

71 lines
2.3 KiB
Markdown
Raw Normal View History

2018-10-08 17:34:43 +00:00
---
title: Identity matrix
id: 5a23c84252665b21eecc7eb1
challengeType: 5
2018-10-10 20:20:40 +00:00
videoUrl: ''
localeTitle: Matriz de identidad
2018-10-08 17:34:43 +00:00
---
## Description
2018-10-10 20:20:40 +00:00
<section id="description"> Una <i>matriz de identidad</i> es una matriz cuadrada de tamaño \ (n \ tiempos n \), donde los elementos diagonales son todos <b>1</b> s (unos), y todos los demás elementos son todos <b>0</b> s (ceros). \ begin {bmatrix} 1 &amp; 0 &amp; 0 \ cr 0 &amp; 1 &amp; 0 \ cr 0 &amp; 0 &amp; 1 \ cr \ end {bmatrix} Escriba una función que tome un número &#39;n&#39; como parámetro y devuelva la matriz de identidad de orden nx n. </section>
2018-10-08 17:34:43 +00:00
## Instructions
2018-10-10 20:20:40 +00:00
<section id="instructions">
2018-10-08 17:34:43 +00:00
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>idMatrix</code> debería ser una función.
testString: 'assert(typeof idMatrix=="function","<code>idMatrix</code> should be a function.");'
- text: <code>idMatrix(1)</code> debería devolver una matriz.
testString: 'assert(Array.isArray(idMatrix(1)),"<code>idMatrix(1)</code> should return an array.");'
2018-10-10 20:20:40 +00:00
- text: '<code>idMatrix(1)</code> debe devolver <code>&quot;+JSON.stringify(results[0])+&quot;</code> .'
2018-10-08 17:34:43 +00:00
testString: 'assert.deepEqual(idMatrix(1),results[0],"<code>idMatrix(1)</code> should return <code>"+JSON.stringify(results[0])+"</code>.");'
2018-10-10 20:20:40 +00:00
- text: '<code>idMatrix(2)</code> debe devolver <code>&quot;+JSON.stringify(results[1])+&quot;</code> .'
2018-10-08 17:34:43 +00:00
testString: 'assert.deepEqual(idMatrix(2),results[1],"<code>idMatrix(2)</code> should return <code>"+JSON.stringify(results[1])+"</code>.");'
2018-10-10 20:20:40 +00:00
- text: '<code>idMatrix(3)</code> debe devolver <code>&quot;+JSON.stringify(results[2])+&quot;</code> .'
2018-10-08 17:34:43 +00:00
testString: 'assert.deepEqual(idMatrix(3),results[2],"<code>idMatrix(3)</code> should return <code>"+JSON.stringify(results[2])+"</code>.");'
2018-10-10 20:20:40 +00:00
- text: '<code>idMatrix(4)</code> debe devolver <code>&quot;+JSON.stringify(results[3])+&quot;</code> .'
2018-10-08 17:34:43 +00:00
testString: 'assert.deepEqual(idMatrix(4),results[3],"<code>idMatrix(4)</code> should return <code>"+JSON.stringify(results[3])+"</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function idMatrix (n) {
// Good luck!
}
2018-10-10 20:20:40 +00:00
2018-10-08 17:34:43 +00:00
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
2018-10-10 20:20:40 +00:00
// solution required
2018-10-08 17:34:43 +00:00
```
</section>