Fixed formatting of the 24 Game | Rosetta challenge

This commit is contained in:
The Coding Aviator
2019-02-24 20:09:41 +05:30
committed by Kristofer Koishigawa
parent 45f5a8d6b8
commit f8061bcb56

View File

@ -6,22 +6,22 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>Implement a function that takes a string of four digits as its argument, with each digit from 1 ──► 9 (inclusive) with repetitions allowed, and returns an arithmetic expression that evaluates to the number 24. If no such solution exists, return "no solution exists."</p> <p>Implement a function that takes a string of four digits as its argument, with each digit from 1 to 9 (inclusive) with repetitions allowed, and returns an arithmetic expression that evaluates to the number 24. If no such solution exists, return "no solution exists."</p>
<p>Rules:</p>
Only the following operators/functions are allowed: multiplication, division, addition, subtraction ### Rules:
Division should use floating point or rational arithmetic, etc, to preserve remainders. <ul>
Forming multiple digit numbers from the supplied digits is disallowed. (So an answer of 12+12 when given 1, 2, 2, and 1 is wrong). <li> Only the following operators/functions are allowed: multiplication, division, addition, subtraction. </li>
The order of the digits when given does not have to be preserved. <li> Division should use floating point or rational arithmetic, etc, to preserve remainders. </li>
<p>Example inputs:</p> <li> Forming multiple digit numbers from the supplied digits is disallowed. (So an answer of 12+12 when given 1, 2, 2, and 1 is wrong). </li>
<code>solve24("4878");</code> <li> The order of the digits when given does not have to be preserved. </li>
<code>solve24("1234");</code> </ul>
<code>solve24("6789");</code>
<code>solve24("1127");</code> | Example input | Example output |
<p>Example outputs (strings):</p> | --- | --- |
<code>(7-8/8)*4</code> | <code>solve24("4878");</code> | <code>(7-8/8)*4</code> |
<code>3*1*4*2</code> | <code>solve24("1234");</code> | <code>3*1*4*2</code> |
<code>(6*8)/(9-7)</code> | <code>solve24("6789");</code> | <code>(6*8)/(9-7)</code> |
<code>(1+7)*(2+1)</code> | <code>solve24("1127");</code> | <code>(1+7)*(2+1)</code> |
</section> </section>
## Instructions ## Instructions
@ -55,7 +55,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function solve24 (numStr) { function solve24 (numStr){
// Good luck! // Good luck!
return true; return true;
} }
@ -99,7 +99,7 @@ function include(ansArr, res) {
```js ```js
// noprotect // noprotect
function solve24 (numStr) { function solve24 (numStr){
const digitsArr = numStr.split(''); const digitsArr = numStr.split('');
const answers = []; const answers = [];