31 lines
1.4 KiB
Text
31 lines
1.4 KiB
Text
;Task:
|
|
Find solutions to the <big> ''sum to one hundred'' </big> puzzle.
|
|
|
|
|
|
Add (insert) the mathematical
|
|
operators <big> '''+''' </big> or <big><big> '''-''' </big></big> (plus
|
|
or minus) before any of the digits in the
|
|
<br>decimal numeric string <big> '''123456789''' </big> such that the
|
|
resulting mathematical expression adds up to a
|
|
<br>particular sum (in this iconic case, '''100''').
|
|
|
|
|
|
Example:
|
|
<big> <big> <b> <big> 123 + 4 - 5 + 67 - 89 = 100 </big> </b> </big> </big>
|
|
|
|
Show all output here.
|
|
|
|
|
|
:* Show all solutions that sum to <big> '''100''' </big>
|
|
:* Show the sum that has the maximum ''number'' of solutions (from zero to infinity<sup><big>‡</big></sup>)
|
|
:* Show the lowest positive sum that ''can't'' be expressed (has no solutions), using the rules for this task
|
|
:* Show the ten highest numbers that can be expressed using the rules for this task (extra credit)
|
|
<br>
|
|
|
|
<sup><big>‡</big></sup> (where ''infinity'' would be a relatively small 123,456,789)
|
|
|
|
|
|
An example of a sum that can't be expressed (within the rules of this task) is: '''5074'''
|
|
<br>(which, of course, isn't the lowest positive sum that can't be expressed).
|
|
<br><br>
|
|
|