Bulls and cows/Player: Difference between revisions
m
→{{header|Perl 6}}: fixed calculation of $exact, add sample output
No edit summary |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: fixed calculation of $exact, add sample output) |
||
Line 1,823:
=={{header|Perl 6}}==
{{works with|Rakudo|2018.
{{trans|Perl}}
Line 1,840:
# they are needed and saves us a lot of arguments to our two routines.
sub score-correct($a) {
▲ my $exact = [+] $a Z== $guess;
# number of elements of $a that match any element of $b
Line 1,855 ⟶ 1,852:
my $score = prompt "My guess: {$guess.join}.\n";
if $score ~~ m:s/^ $<bulls>=(\d) $<cows>=(\d) $/
and $<bulls> + $<cows> <= 4 {
Line 1,871 ⟶ 1,865:
?? "Your secret number is {@candidates[0].join}!"
!! "I think you made a mistake with your scoring.";</lang>
{{out}}
<pre>My guess: 4235.
2 1
My guess: 1435.
2 1
My guess: 1245.
2 1
Your secret number is 1234!</pre>
=={{header|Phix}}==
|