Bulls and cows: Difference between revisions

Content added Content deleted
(Add SETL)
(added RPL)
Line 6,363: Line 6,363:
end
end
</syntaxhighlight>
</syntaxhighlight>
=={{header|RPL}}==
{{works with|HP|49}}
« CLEAR 0 ""
1 4 '''START'''
'''WHILE''' RAND 9 * CEIL R→I →STR DUP2 POS '''REPEAT''' '''DROP''' END +
'''NEXT'''
→ count solution
« '''DO''' 1 CF
'''DO''' "Guess? [CONT]" PROMPT →STR
'''CASE'''
DUP SIZE 4 ≠ '''THEN''' DROP "Not 4 characters" 1 DISP 0.5 WAIT '''END'''
{ 9 } 0 CON
1 4 '''FOR''' j
OVER j DUP SUB STR→
'''IFERR''' 1 PUT '''THEN''' 3 DROPN "Invalid character" 1 DISP 0.5 WAIT '''END'''
'''NEXT'''
DUP 1 CON DOT 4 ≠ '''THEN''' DROP "Repeated digits" 1 DISP 0.5 WAIT '''END'''
1 SF
'''END'''
'''UNTIL''' 1 FS? '''END'''
" → " + 0
1 4 '''FOR''' j
solution PICK3 j DUP SUB POS
'''IF''' DUP '''THEN''' IF j == '''THEN''' 1 '''ELSE''' .1 '''END END''' +
'''NEXT'''
SWAP OVER + 'count' INCR DROP
'''UNTIL''' SWAP 4 == '''END'''
count "guess" →TAG
» » '<span style="color:blue">BU&CO</span>' ST0

=={{header|Ruby}}==
=={{header|Ruby}}==
Inspired by Tcl
Inspired by Tcl
Line 6,445: Line 6,475:
puts "Bulls: #{bulls}; Cows: #{cows}"
puts "Bulls: #{bulls}; Cows: #{cows}"
end</syntaxhighlight>
end</syntaxhighlight>

=={{header|Rust}}==
=={{header|Rust}}==
{{libheader|rand}}
{{libheader|rand}}