Anonymous user
16 puzzle game: Difference between revisions
m
→{{header|REXX}}: changed quote styles.
m (added a related task.) |
m (→{{header|REXX}}: changed quote styles.) |
||
Line 25:
<br>Not all errors are checked so as to keep the program simpler.
<lang rexx>/*REXX pgm implements the 16 game; displays game grid, prompts for a move, game won? */
sep= copies(
parse arg N hard seed . /*obtain optional arguments from the CL*/
er= '***error***' /*literal used to indicate an error msg*/
Line 42:
do hard; row= random(1) /*scramble the grid HARD # of times.*/
if row then call move random(1,N)substr('LR', random(1, 2), 1) /* ◄── move row. */
else call move substr('abcdefghi',random(1,N), 1)substr(
end /*hard*/ /* [↓] move col.*/
/*play 16─game until solved or quit.*/
Line 97:
bot= '╚'copies( copies("═", 2)'╩', N); bot= left( bot, length(bot) - 1)"╝"
ind= left('', 3 + length(N) ) /*compute indentation.*/
col= ind ind ind' ' subword(
HI= substr('abcdefghi', N, 1); upper HI
say col ind ind ind '- means shift a column down'; say pad ind top
Line 109:
end /*r*/
say pad ind bot; say;
say translate(col, '+', "-") ind ind ind
return</lang>
{{out|output|text= when using the default inputs:}}
|