Bulls and cows: Difference between revisions

Content added Content deleted
No edit summary
m (added whitespace before the TOC (table of contents), added a ;Task: (bold) header, added other whitespace and highlighting to the task's preamble, used article name for link instead of "This".)
Line 1: Line 1:
{{task|Games}}
{{task|Games}}
[[wp:Bulls and Cows|This]] is an old game played with pencil and paper that was later implemented on computer.


[[wp:Bulls and Cows|Bulls and Cows]]   is an old game played with pencil and paper that was later implemented using computers.
The task is for the program to create a four digit random number from the digits 1 to 9, without duplication.

The program should ask for guesses to this number, reject guesses that are malformed, then print the score for the guess.

;Task:
Create a four digit random number from the digits   '''1'''   to   '''9''',   without duplication.

The program should:
::::::*   ask for guesses to this number
::::::*   reject guesses that are malformed
::::::*   print the score for the guess



The score is computed as:
The score is computed as:
Line 10: Line 18:
# A score of one '''cow''' is accumulated for each digit in the guess that also appears in the randomly chosen number, but in the wrong position.
# A score of one '''cow''' is accumulated for each digit in the guess that also appears in the randomly chosen number, but in the wrong position.



;Cf,
;C.f.:
* [[Bulls and cows/Player]]
* [[Bulls and cows/Player]]
* [[Guess the number]]
* [[Guess the number]]
* [[Guess the number/With Feedback]]
* [[Guess the number/With Feedback]]
<br><br>


=={{header|Ada}}==
=={{header|Ada}}==