24 game/Solve: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: fixed program to generate all manner of groupings.)
(→‎{{header|REXX}}: supported rational arithmetic for solutions to such numbers as 3388.)
Line 5,886: Line 5,886:
└───────────────────────────────────────────────────────────────────────┘
└───────────────────────────────────────────────────────────────────────┘
end-of-help */
end-of-help */
numeric digits 12 /*where rational arithmetic is needed. */
parse arg orig /*get the guess from the command line*/
parse arg orig /*get the guess from the command line*/
orig= space(orig, 0) /*remove all blanks from ORIG. */
orig= space(orig, 0) /*remove all blanks from ORIG. */
Line 6,058: Line 6,059:
x.e= 1 /*mark this expression as being used. */
x.e= 1 /*mark this expression as being used. */
end
end
interpret 'x=(' e ") / 1" /*have REXX do the heavy lifting here. */
interpret 'x=(' e ") / 1" /*have REXX do the heavy lifting here. */
if x\==?? then iterate /*Not correct? Then try again. */
if x\==?? then do /*Not correct? Then try again. */
finds= finds + 1 /*bump number of found solutions. */
numeric digits 9; x= x / 1 /*re-do evaluation.*/
numeric digits 12 /*re-instate digits*/
if x\==?? then iterate /*Not correct? Then try again. */
end
finds= finds + 1 /*bump number of found solutions. */
if \show | negatory then return finds
if \show | negatory then return finds
_= translate(origE, '][', ")(") /*show [], not (). */
_= translate(origE, '][', ")(") /*show [], not (). */