Anonymous user
Bulls and cows/Player: Difference between revisions
m
→{{header|REXX}}: added better checks for guesses that contain a zero digit.
m (→{{header|REXX}}: added better checks for guesses that contain a zero digit.) |
|||
Line 2,512:
do tries=1 until #()<2 | bull==4; say
call prompter
do ?=
if @.?==. then iterate /*was this choice already eliminated ? */
call bull# ?,g /*obtain the bulls and cows count. */
Line 2,529:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
#: #=0; do k=
gen@: @.=.;
serr: say; say pad '***error*** ' ! arg(1); return▼
▲serr: say; say pad '***error*** ' ! arg(1); return
/*──────────────────────────────────────────────────────────────────────────────────────*/
bull#: parse arg n,q; L=length(n); bulls=0; cows=0 /*initialize some vars.*/
Line 2,550 ⟶ 2,549:
do forever; say
say pad "How many bulls and cows were guessed with " g '? [─── or QUIT]'
pull x 1 bull cow
if abbrev('QUIT', x, 1) then exit /*the user wants to quit playing.*/
select
when bull == ''
when cow == ''
when
when \datatype(bull, 'W') then != "1st number (bulls) not an integer: " bull
when \datatype(cow , 'W') then != "2nd number (cows) not an integer: " cow
Line 2,564 ⟶ 2,563:
end /*select*/
if !\=='' then do; call serr; iterate; end /*prompt the user and try again. */
bull=bull / 1;
end /*forever*/</lang> <br><br>
=={{header|Ring}}==
|