McNuggets problem: Difference between revisions

m
→‎{{header|REXX}}: corrected misspellings.
(→‎{{header|REXX}}: added the REXX computer programming language.)
m (→‎{{header|REXX}}: corrected misspellings.)
Line 53:
 
=={{header|REXX}}==
<lang rexx>/*REXX pgm solves the NcNuggetsMcNuggets problem: the largest NcNuggetMcNugget number for given meals. */
parse arg y /*obtain optional arguments from the CL*/
if y='' | y="," then y= 6 9 20 /*Not specified? Then use the defaults*/
say 'The number of McNuggets in the serving sizes of: ' space(y)
$=
#= 0 /*the Y list must be in assendingascending order*/
z=.
do j=1 for words(y); _= word(y, j) /*examine Y list for dups, neg, zereszeros*/
if _==1 then signal done /*Value ≡ 1? Then all values possibblepossible.*/
if _<1 then iterate /*ignore zero and negative # of nuggets*/
if wordpos(_, $)\==0 then iterate /*search for duplicate values. */
Line 91:
end /*z*/
say
done: if z==. then say 'The largest NcNuggetsMcNuggets number not possible.'
else say 'The largest NcNuggetsMcNuggets number is: ' z
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 100:
do until y==0; parse value x//y y with y x; end
end; return x<lang>
{{out|output|text=&nbsp; when using the default inputs:}}
 
<pre>
The number of McNuggets in the serving sizes of: 6 9 20
 
The largest McNuggets number is: 43
</pre>