Jump to content

Bulls and cows/Player: Difference between revisions

m
→‎{{header|R}}: Syntax highlighting.
m (→‎{{header|Phix}}: added syntax colouring, made p2js compatible)
m (→‎{{header|R}}: Syntax highlighting.)
Line 2,933:
=={{header|R}}==
As we are picking our guesses randomly from the remaining valid guesses, it is likely that this solution is neither optimal, efficient, or particularly smart. However, it is much shorter than some of the other solutions, is reasonably idiomatic R, and does not break in any way that I know of. I am aware that there exists an optimal method of playing this game, but I neither know the algorithm nor was required by the task to implement it. For comparison, it would be interesting to see the optimal method submitted here as an alternative solution.
<lang rrsplus>bullsAndCowsPlayer<-function()
{
guesses<-1234:9876
Line 2,970:
My guess is 1736. Bull score? [0-4] 4
[1] "Your number is 1736. I win!"</pre>
 
=={{header|Racket}}==
Generate the list of possible choices. Each choice is represented as list of 4 numbers.
331

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.