Department numbers: Difference between revisions

m
→‎{{header|REXX}}: added a comment to the REXX section header (about optimizing statements), added a couple of comments to the REXX code.
m (→‎{{header|REXX}}: added a comment to the REXX section header (about optimizing statements), added a couple of comments to the REXX code.)
Line 729:
=={{header|REXX}}==
A little extra code was added to allow the specification for the high department number as well as the sum.
 
Two optimizing statements were added (for speed).
 
Also, extra code was added to nicely format a title (header) for the output, as well as displaying the number of solutions found.
Line 741 ⟶ 743:
do FD=1 for high /* " " " " fire " */
if FD==PD then iterate /*Same FD# & PD#? They must be unique.*/
if FD+PD>sum-1 then iterate PD /*Is sum too large? Try another PD#. */ /* ◄■■■■■■ optimizing code*/
do SD=1 for high /*try numbers for the sanitation dept. */
if SD==PD | SD==FD then iterate /*Is SD# ¬unique? They must be unique,*/
$=PD+FD+SD /*compute sum of department numbers. */
if $> sum then iterate FD /*Is the sum too high? Try another FD#*/ /* ◄■■■■■■ optimizing code*/
if $\==sum then iterate /*Is the sum ¬correct? " " SD#*/
#=# + 1 /*bump the number of solutions (so far)*/