16 puzzle game: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: corrected a misspelling.)
m (→‎{{header|REXX}}: corrected misspellings.)
Line 29: Line 29:
if N<2 | N>9 then do; say sep er "grid size is out of range: " N; exit 1; end
if N<2 | N>9 then do; say sep er "grid size is out of range: " N; exit 1; end
if isInt(seed) then call random , , seed /*use repeatability seed for RANDOM BIF*/
if isInt(seed) then call random , , seed /*use repeatability seed for RANDOM BIF*/
say sep 'Playing a ' N*N " game with a difficulity level of: " hard
say sep 'Playing a ' N*N " game with a difficulty level of: " hard
#=0
#=0
do r=1 for N /* [◄] build a solution for testing. */
do r=1 for N /* [◄] build a solution for testing. */
Line 35: Line 35:
end /*c*/
end /*c*/
end /*r*/
end /*r*/
/* [↓] HARD is the puzzle difficulity*/
/* [↓] HARD is the puzzle difficulty.*/
do hard; row= random(1) /*scramble the grid HARD # of times.*/
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. */
if row then call move random(1,N)substr('LR', random(1, 2), 1) /* ◄── move row. */
Line 99: Line 99:
do c=1 for N; z= z || right(@.r.c, 2)'║' /*build row by row. */
do c=1 for N; z= z || right(@.r.c, 2)'║' /*build row by row. */
end /*c*/
end /*c*/
z= z ' ' r"L" /*add rightside info.*/
z= z ' ' r"L" /*add right-side info*/
if r==1 then z= z pad'L means shift a row left' /* " 1st help info.*/
if r==1 then z= z pad'L means shift a row left' /* " 1st help info.*/
if r==2 then z= z pad'R means shift a row right' /* " 2nd " " */
if r==2 then z= z pad'R means shift a row right' /* " 2nd " " */
Line 109: Line 109:
{{out|output|text=&nbsp; when using the default inputs:}}
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
<pre>
──────── Playing a 16 game with a difficulity level of: 2
──────── Playing a 16 game with a difficulty level of: 2


a- b- c- d- - means shift a column down
a- b- c- d- - means shift a column down