Bulls and cows/Player: Difference between revisions

m
Fix variable name typo
m (Fix variable name typo)
 
(4 intermediate revisions by 2 users not shown)
Line 146:
Testant : constant Sequence := V.Element (Position);
Bull_Score : Natural := 0;
Cows_ScoreCow_Score : Natural := 0;
begin
for I in Testant'Range loop
Line 252:
Cows:2
The sequence you thought has to be: 8 3 9 5</pre>
 
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">
Line 1,370 ⟶ 1,371:
end fn
 
void local fn growWindow
CGRect r = fn WindowContentRect( 1 )
r.size.height += 32
Line 1,377 ⟶ 1,378:
end fn
 
void local fn init //Create array of possible 4-digit numbers
uint8 d1,d2,d3,d4
for d1 = 1 to 9
Line 1,400 ⟶ 1,401:
state = 1 : stock = 0 : y = 60
fn growWindow
text @"menlo bold",24,fn ColorControlText,fn ColorWindowBackground
fn showGuess
end fn
Line 1,471 ⟶ 1,472:
DialogEventSetBool(YES) : fn play( intval( ch ) )
end if
//if fn StringIsEqual( ch, @"?" ) then window 2
case _btnClick : fn NewGame : window -2
case _windowShouldClose_windowWillClose : if tag == 1 then end //else window -2 : DialogEventSetBool(YES)
end select
end fn
Line 1,486 ⟶ 1,487:
{{out}}
[[File:Bull and Cows Solver in FB.png]]
 
=={{header|Go}}==
Notes: Strategy per the suggestion in the problem description. Check algorithm lifted from Bulls and cows program. Code here uses Go's built in map type as the container for the list of still-possible numbers; only the map key is used, the value is assigned a dummy of 0.
Line 4,353 ⟶ 4,355:
=={{header|Wren}}==
{{trans|Kotlin}}
<syntaxhighlight lang="ecmascriptwren">import "random" for Random
 
var countBullsAndCows = Fn.new { |guess, answer|
Line 4,425 ⟶ 4,427:
You've just found the answer!
</pre>
 
=={{header|Yabasic}}==
{{trans|Liberty BASIC}}
2

edits