fix(challenges): I problems

This commit is contained in:
Kris Koishigawa
2019-03-06 14:18:18 +09:00
committed by mrugesh
parent a3fd1aa284
commit 263d2c496b
4 changed files with 41 additions and 36 deletions

View File

@ -6,16 +6,22 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
The phrase <a href="https://en.wikipedia.org/wiki/I before E except after C"> "I before E, except after C"</a> is a widely known mnemonic which is supposed to help when spelling English words. The phrase <a href="https://en.wikipedia.org/wiki/I before E except after C" target="_blank"> "I before E, except after C"</a> is a widely known mnemonic which is supposed to help when spelling English words.
Using the words provided, check if the two sub-clauses of the phrase are plausible individually: Using the words provided, check if the two sub-clauses of the phrase are plausible individually:
<ol><li style='margin-bottom: 5px;'><i>"I before E when not preceded by C".</i></li><li><i>"E before I when preceded by C".</i></li></ol> <ol>
<li>
<i>"I before E when not preceded by C".</i>
</li>
<li>
<i>"E before I when preceded by C".</i>
</li>
</ol>
If both sub-phrases are plausible then the original phrase can be said to be plausible. If both sub-phrases are plausible then the original phrase can be said to be plausible.
Write a function that accepts a word and check if the word follows this rule. The function should return true if it follows the rule otherwise false.
</section> </section>
## Instructions ## Instructions
<section id='instructions'> <section id='instructions'>
Write a function that accepts a word and check if the word follows this rule. The function should return true if the word follows the rule and false if it does not.
</section> </section>
## Tests ## Tests
@ -50,7 +56,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function IBeforeExceptC (word) { function IBeforeExceptC(word) {
// Good luck! // Good luck!
} }
``` ```
@ -66,7 +72,7 @@ function IBeforeExceptC (word) {
```js ```js
function IBeforeExceptC (word) function IBeforeExceptC(word)
{ {
if(word.indexOf("c")==-1 && word.indexOf("ie")!=-1) if(word.indexOf("c")==-1 && word.indexOf("ie")!=-1)
return true; return true;

View File

@ -6,20 +6,19 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
The <a href="https://en.wikipedia.org/wiki/International_Bank_Account_Number">International Bank Account Number (IBAN)</a> is an internationally agreed means of identifying bank accounts across national borders with a reduced risk of propagating <a href="https://en.wikipedia.org/wiki/Transcription_error">transcription errors</a>. The <a href="https://en.wikipedia.org/wiki/International_Bank_Account_Number" target="_blank">International Bank Account Number (IBAN)</a> is an internationally agreed means of identifying bank accounts across national borders with a reduced risk of propagating <a href="https://en.wikipedia.org/wiki/Transcription_error" target="_blank">transcription errors</a>.
The IBAN consists of up to 34 alphanumeric characters: The IBAN consists of up to 34 alphanumeric characters:
<ul> <ul>
<li>first the two-letter ISO 3166-1 alpha-2 country code</li> <li>first the two-letter ISO 3166-1 alpha-2 country code</li>
<li>then two check digits, and</li> <li>then two check digits, and</li>
<li>finally a country-specific Basic Bank Account Number (BBAN).</li> <li>finally a country-specific Basic Bank Account Number (BBAN).</li>
</ul> </ul>
The check digits enable a sanity check of the bank account number to confirm its integrity even before submitting a transaction. The check digits enable a sanity check of the bank account number to confirm its integrity even before submitting a transaction.
Write a function that takes IBAN string as parameter. If it is valid return true. Otherwise, return false.
</section> </section>
## Instructions ## Instructions
<section id='instructions'> <section id='instructions'>
Write a function that takes IBAN string as parameter. If it is valid return true. Otherwise, return false.
</section> </section>
## Tests ## Tests
@ -52,7 +51,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function isValid (iban) { function isValid(iban) {
// Good luck! // Good luck!
} }
``` ```
@ -66,7 +65,7 @@ function isValid (iban) {
```js ```js
function isValid (iban) { function isValid(iban) {
var ibanLen = { var ibanLen = {
NO:15, BE:16, DK:18, FI:18, FO:18, GL:18, NL:18, MK:19, NO:15, BE:16, DK:18, FI:18, FO:18, GL:18, NL:18, MK:19,
SI:19, AT:20, BA:20, EE:20, KZ:20, LT:20, LU:20, CR:21, SI:19, AT:20, BA:20, EE:20, KZ:20, LT:20, LU:20, CR:21,

View File

@ -6,16 +6,15 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
An <i>identity matrix</i> is a square matrix of size \( n \times n \), An <i>identity matrix</i> is a square matrix of size \( n \times n \), where the diagonal elements are all <b>1</b>s (ones), and all the other elements are all <b>0</b>s (zeroes).
where the diagonal elements are all <b>1</b>s (ones), <ul>
and all the other elements are all <b>0</b>s (zeroes). <li style="list-style: none;">\(\displaystyle I_{n}=\begin{bmatrix} 1 & 0 & 0 \cr 0 & 1 & 0 \cr 0 & 0 & 1 \cr \end{bmatrix}\)</li>
\begin{bmatrix} 1 & 0 & 0 \cr 0 & 1 & 0 \cr 0 & 0 & 1 \cr \end{bmatrix} </ul>
Write a function that takes a number 'n' as a parameter and returns the identity matrix of order n x n.
</section> </section>
## Instructions ## Instructions
<section id='instructions'> <section id='instructions'>
Write a function that takes a number <code>n</code> as a parameter and returns the identity matrix of order \( n \times n \).
</section> </section>
## Tests ## Tests
@ -27,14 +26,14 @@ tests:
testString: assert(typeof idMatrix=='function','<code>idMatrix</code> should be a function.'); testString: assert(typeof idMatrix=='function','<code>idMatrix</code> should be a function.');
- text: <code>idMatrix(1)</code> should return an array. - text: <code>idMatrix(1)</code> should return an array.
testString: assert(Array.isArray(idMatrix(1)),'<code>idMatrix(1)</code> should return an array.'); testString: assert(Array.isArray(idMatrix(1)),'<code>idMatrix(1)</code> should return an array.');
- text: <code>idMatrix(1)</code> should return <code>'+JSON.stringify(results[0])+'</code>. - text: <code>idMatrix(1)</code> should return <code>[ [ 1 ] ]</code>.
testString: assert.deepEqual(idMatrix(1),results[0],'<code>idMatrix(1)</code> should return <code>'+JSON.stringify(results[0])+'</code>.'); testString: assert.deepEqual(idMatrix(1),results[0]);
- text: <code>idMatrix(2)</code> should return <code>'+JSON.stringify(results[1])+'</code>. - text: <code>idMatrix(2)</code> should return <code>[ [ 1, 0 ], [ 0, 1 ] ]</code>.
testString: assert.deepEqual(idMatrix(2),results[1],'<code>idMatrix(2)</code> should return <code>'+JSON.stringify(results[1])+'</code>.'); testString: assert.deepEqual(idMatrix(2),results[1]);
- text: <code>idMatrix(3)</code> should return <code>'+JSON.stringify(results[2])+'</code>. - text: <code>idMatrix(3)</code> should return <code>[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]</code>.
testString: assert.deepEqual(idMatrix(3),results[2],'<code>idMatrix(3)</code> should return <code>'+JSON.stringify(results[2])+'</code>.'); testString: assert.deepEqual(idMatrix(3),results[2]);
- text: <code>idMatrix(4)</code> should return <code>'+JSON.stringify(results[3])+'</code>. - text: <code>idMatrix(4)</code> should return <code>[ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ]</code>.
testString: assert.deepEqual(idMatrix(4),results[3],'<code>idMatrix(4)</code> should return <code>'+JSON.stringify(results[3])+'</code>.'); testString: assert.deepEqual(idMatrix(4),results[3]);
``` ```
@ -46,7 +45,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function idMatrix (n) { function idMatrix(n) {
// Good luck! // Good luck!
} }
``` ```
@ -73,7 +72,7 @@ let results=[[ [ 1 ] ],
```js ```js
function idMatrix (n) { function idMatrix(n) {
return Array.apply(null, new Array(n)).map(function (x, i, xs) { return Array.apply(null, new Array(n)).map(function (x, i, xs) {
return xs.map(function (_, k) { return xs.map(function (_, k) {
return i === k ? 1 : 0; return i === k ? 1 : 0;

View File

@ -7,14 +7,15 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
If you add the square of the digits of a Natural number (an integer bigger than zero), you always end with either 1 or 89: If you add the square of the digits of a Natural number (an integer bigger than zero), you always end with either 1 or 89:
<pre>15 -> 26 -> 40 -> 16 -> 37 -> 58 -> 89 <pre>
7 -> 49 -> 97 -> 130 -> 10 -> 1</pre> 15 -> 26 -> 40 -> 16 -> 37 -> 58 -> 89
Write a function that takes a number as a parameter and returns 1 or 89 after performing the mentioned process. 7 -> 49 -> 97 -> 130 -> 10 -> 1
</pre>
</section> </section>
## Instructions ## Instructions
<section id='instructions'> <section id='instructions'>
Write a function that takes a number as a parameter and returns 1 or 89 after performing the mentioned process.
</section> </section>
## Tests ## Tests
@ -49,7 +50,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function iteratedSquare (n) { function iteratedSquare(n) {
// Good luck! // Good luck!
} }
``` ```
@ -65,7 +66,7 @@ function iteratedSquare (n) {
```js ```js
function iteratedSquare (n) { function iteratedSquare(n) {
var total; var total;
while (n != 89 && n != 1) { while (n != 89 && n != 1) {
total = 0; total = 0;