Sudoku/REXX: Difference between revisions
→REXX version 3
(fixed some HTML headers.) |
|||
(8 intermediate revisions by 3 users not shown) | |||
Line 1:
{{collection|Sudoku}}
==
=== REXX
This is the
The REXX program was written to give increasing better hints and also show the possibilities (of what is possible solution for any cell),
<br>and to partially solve the puzzle using distinct strategies (separately or in combination). One option is to solve the puzzle.
The help for the <code>$SUDOKU</code> REXX program is included here ───► [[$SUDOKU.HEL]].
The <code>$ERR.REX</code> REXX program is included here ───► [[$ERR.REX]].
The <code>$SUDOKU.REX</code> REXX program makes use of <code>$T.REX</code> REXX program which is used to display text messages.
The <code>$T.REX</code> REXX program is included here ───► [[$T.REX]].
Some older REXXes don't have a '''changestr''' BIF, so one is included here ───► [[CHANGESTR.REX]].
REXX programs ''not'' included are <code>$H</code> which shows/displays '''help''' and other documentation.
<syntaxhighlight lang="rexx">
/*REXX program displays, can give hints, and/or solve a sudoku puzzle. */
trace off
parse arg !
Line 819 ⟶ 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</
This REXX program makes use of '''$ERR.REX''' REXX program
which is used to write (display) error messages to the terminal screen, with
supplemental text that identifies what program issued the error, and in some
cases, also identifies the failing REXX statement and some particulars about
the failure.
The '''$ERR.T.REX''' REXX program can be found here ───► [[$ERR.REX]].
changestr $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@##############%%%%%%%%%%%%%%%%%%%
{{out|output| when using the input of: <br>
<tt> row 1 .5..7.89 row 2 9...3 row 3 1...89.4 row 4 ..9.....1 row 5 ..13.52 row 6 6.....5 row 7 .6.89...3 row 8 ....5...7 row 9 .98.2..5 pruneALL </tt>}}
<pre style="height:130ex">
$SUDOKU is showing the puzzle
Line 937 ⟶ 957:
</pre>
=== REXX
{{trans|PL/I}}
<syntaxhighlight lang="rexx"> Parse Arg g.0fid
Select
When g.0fid='?' Then Do
Line 2,724 ⟶ 1,169:
Return
exit: Say '*ERROR*' arg(1)
</syntaxhighlight>
{{out}}
<pre>input from d:\_sudoku\in\sdk001.in
Line 2,750 ⟶ 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>
=== REXX
This is version 1 (thanks) cut to the essentials, restructured, and modified
<syntaxhighlight lang="rexx">
/* REXX ---------------------------------------------------------------
* program to solve nearly every SUDOKU puzzle
* using a number of strategies learned from REXX version 1
Line 3,756 ⟶ 2,205:
Nop
End
Exit 12
</syntaxhighlight>
{{out}}
<pre>
process file sdk087.in
Input from sdk087.in
Debug output to 0
Line 3,769 ⟶ 2,220:
. . . . 7 1 5 . .
. . 2 4 . 6 . 1 8
. . . . . 9 . 4 6
. 9 . 6 1 8 . 3 .
6 1 . 7 . . . . 9
4 3 . 8 . 7 6 . .
. . 8 1 4 . . . .
. . 9 . . . . . .
solved
7 4 1 9 8 5 3 6 2
3 8 6 2 7 1 5 9 4
9 5 2 4 3 6 7 1 8
8 2 7 3 5 9 1 4 6
5 9 4 6 1 8 2 3 7
6 1 3 7 2 4 8 5 9
4 3 5 8 9 7 6 2 1
2 6 8 1 4 3 9 7 5
1 7 9 5 6 2 4 8 3
</pre>
|