Fixed formatting of the 24 Game | Rosetta challenge
This commit is contained in:
committed by
Kristofer Koishigawa
parent
45f5a8d6b8
commit
f8061bcb56
@ -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
|
||||||
|
Reference in New Issue
Block a user