Sudoku/REXX: Difference between revisions

m (moved the HELp file to it's own page.)
 
(5 intermediate revisions by 3 users not shown)
Line 1:
{{collection|Sudoku}}
 
=={{header|[[REXX}}]]==
=== REXX version 1 ===
This is the &nbsp; '''<code>$SUDOKU.REX''' &nbsp;</code> (REXX) program and is used to solve the Rosetta Code task of "sudoku".
 
 
This REXX program was originally written to assist in sudoku puzzle solving (by giving strong hints), and not to solve the puzzle outright.
Line 11 ⟶ 10:
<br>and to partially solve the puzzle using distinct strategies (separately or in combination). &nbsp; One option is to solve the puzzle.
 
The help for the &nbsp; '''<code>$SUDOKU''' &nbsp;</code> REXX program is included here &nbsp; ───► &nbsp; [[$SUDOKU.HEL]].
 
The &nbsp; '''<code>$SUDOKU.REX''' &nbsp;</code> REXX program makes use of &nbsp; '''<code>$ERR.REX''' &nbsp;</code> REXX program which is used to display error messages (via &nbsp; '''$T.REX''').
 
The &nbsp; '''<code>$ERR.REX''' &nbsp;</code> REXX program is included here &nbsp; ───► &nbsp; [[$ERR.REX]].
 
The &nbsp; '''<code>$SUDOKU.REX''' &nbsp;</code> REXX program makes use of &nbsp; '''<code>$T.REX''' &nbsp;</code> REXX program which is used to display text messages.
 
The &nbsp; '''<code>$T.REX''' &nbsp;</code> REXX program is included here &nbsp; ───► &nbsp; [[$T.REX]].
 
Some older REXXes don't have a &nbsp; '''changestr''' &nbsp; BIF, so one is included here &nbsp; ───► &nbsp; [[CHANGESTR.REX]].
 
REXX programs &nbsp; ''not'' &nbsp; included are &nbsp; '''<code>$H''' &nbsp;</code> which shows/displays '''help''' and other documentation.
<syntaxhighlight lang="rexx">
<lang rexx>/*REXX program displays, can give hints, and/or solve a sudoku puzzle. */
trace off
parse arg !
Line 829:
syntax: !sigl=sigl; call er 13,!fid(2) !fid(3) !sigl !cal() condition('D') sourceline(!sigl)
tem: parse arg r,c,w; if tellInvalid then say '***error!*** row' r", col" c '('@.r.c") is a duplicate of another in the same" w'.'; return 0
tg: arg tg; if simple then tg=simple(tg); call $t gridindent || tg; return</langsyntaxhighlight>
 
 
Line 958:
 
=== REXX version 2 ===
{{trans|PL/I]]}}
<langsyntaxhighlight lang="rexx"> Parse Arg g.0fid
Select
When g.0fid='?' Then Do
Line 1,169:
Return
 
exit: Say '*ERROR*' arg(1)</lang>
</syntaxhighlight>
 
{{out}}
<pre>input from d:\_sudoku\in\sdk001.in
Line 1,195 ⟶ 1,197:
8 4 1 2 6 9 7 5 3
2 5 3 7 1 4 9 8 6
9 7 6 3 5 8 1 2 4</pre>
</pre>
 
=== REXX version 3 ===
This is version 1 (thanks) cut to the essentials, restructured, and modified
<syntaxhighlight lang="rexx">
<lang rexx>/* REXX ---------------------------------------------------------------
* program to solve nearly every SUDOKU puzzle
* using a number of strategies learned from REXX version 1
Line 2,201 ⟶ 2,205:
Nop
End
Exit 12</lang>
</syntaxhighlight>
{{out}}
<pre>