Jump to content

Bulls and cows: Difference between revisions

m
imported>Arakov
Line 2,164:
 
=={{header|EasyLang}}==
<syntaxhighlight lang="text">
dig[] = [ 1 2 3 4 5 6 7 8 9 ]
for i = 1 to 4
h = i - 1 + randomrandint (10 - i)
swap dig[i] dig[h]
.
# print dig[]
Line 2,174:
attempts = 0
repeat
repeat
ok = 0
s$[] = strchars input
if len s$[] = 4
ok = 1
for i = 1 to 4
g[i] = number s$[i]
if g[i] = 0
ok = 0
.
.
.
. until ok = 1
.
until ok = 1
print g[]
.
attempts += 1
print g[]
attempts +bulls = 10
bulls cows = 0
cows for i = 01 to 4
for i = 1 toif 4g[i] = dig[i]
if g[i] bulls += dig[i]1
bulls += 1else
for j = 1 to 4
else
for j = 1 to 4 if dig[j] = g[i]
if dig[j] cows += g[i]1
cows += 1.
.
.
.
print "bulls:" & bulls & " cows:" & cows
.
print "bulls:" &until bulls & " cows:" &= cows4
until bulls = 4
.
print "Well done! " & attempts & " attempts needed."</syntaxhighlight>
</syntaxhighlight>
 
=={{header|Eiffel}}==
2,056

edits

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