Anonymous user
Number reversal game: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, used a template for the OUTPUTs.
m (→{{header|REXX}}: added/changed comments and whitespace, used a template for the OUTPUTs.) |
|||
Line 2,846:
:::* allows the user to enter '''quit'''
:::* allows the user to halt the game via '''Cntl-Break''' (or equivalent)
<lang rexx>/*REXX
signal on halt /*allows the CBLF to HALT the program.*/
___= copies('─', 9); pad=left('',
say ___ "This game will show you nine random unique digits (1 ──► 9),
say ___
say ___ "up to (and including) that decimal digit.
say ___ "of the digits in ascending order with the fewest tries.
ok= 123456789 /*the result that the string should be.*/
$= /* ◄─── decimal target to be generated.*/
do until length($)==9; _=random(1,
$=$ || _
if $==ok then $= /*string can't be in order, start over.*/
end /*until
do score=1 until $==ok; say /* [↓] display the
parse pull
if abbrev('QUIT',
if length(x)>1 then do; say ___ pad '
if x
g=pos(
if g==0 then say
else $=strip(reverse(left($,
end /*score*/
say;
say ___ pad 'Your score was' score; exit /*stick a fork in it, we're all done. */
halt: say ___ pad 'quitting.'; exit /* " " " " " " " " */</lang>
<pre>
───────── This game will show you nine random unique digits (1 ──► 9),
─────────
───────── up to (and including) that decimal digit.
───────── of the digits in ascending order with the fewest tries.
───────── 613279548 please enter a digit (or Quit):
Line 2,922:
══════════════════════════ Congratulations! ══════════════════════════
───────── Your score was 12
</pre>
|