Anonymous user
Sum to 100: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, aligned statements.
Alpha bravo (talk | contribs) (Added AutoHotkey) |
m (→{{header|REXX}}: added/changed comments and whitespace, aligned statements.) |
||
Line 5,299:
<lang rexx>/*REXX pgm solves a puzzle: using the string 123456789, insert - or + to sum to 100*/
parse arg LO HI . /*obtain optional arguments from the CL*/
if LO=='' | LO=="," then LO=
if HI=='' | HI=="," then HI=
if LO==00 then HI=
ops= '+-'; L= length(ops) + 1
@.=;
mx= 0; mn=
mxL=; mnL=; do j=LO to HI until LO==00 & mn==0
z=
if z> mx then
if z>=mx then do; mxL=mxL j; mx=z; end
if z< mn then
if z<=mn then do; mnL=mnL j; mn=z; end
end /*j*/
if LO==HI then exit 0 /*don't display max
@@= 'number of solutions: '; say
_= words(mxL); say 'sum's(_) "of" mxL ' 's(_,"have",'has') 'the maximum'
_= words(mnL); say 'sum's(_) "of" mnL ' 's(_,"have",'has') 'the minimum'
exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
s:
/*──────────────────────────────────────────────────────────────────────────────────────*/
do
do
do
do
do
do
do
end /*i*/
end /*h*/
end /*g*/
end /*f*/
end /*e*/
end /*d*/
end /*c*/
end /*b*/
end /*a*/
{{out|output|text= when using the default input:}}
<pre>
|