Bulls and cows: Difference between revisions

Line 897:
#var aRandomNumbers := randomControl randomize:9 &array:(1,2,3,4,5,6,7,8,9).
theNumbers := arrayControl copySubarray:aRandomNumbers &from:0 &length:4.
]
 
Line 904:
#var aRow := consoleEx write:"Your Guess ?" readLine.
^ stringControlliteralControl toArray:aRow.
]
 
Line 912:
#var aBulls := Integer new:0.
 
(aGuess Countlength != 4)
? [ aBulls << -1. ]
! [
control from:0 &to:3 &do: &&:i
[
#var ch := aGuess@i.
#var aNumber := convertControlconvertor toInt:(ch Literalliteral).
// check range
Line 925:
// check duplicates
#var duplicate := arrayControl seek:aGuess &foruntil: &&:x [ (x == ch)and:[ x equal &type'object:ch not ] ].
nil != duplicate ?
[
Anonymous user