The Museum of HP Calculators


Cows and Bulls (Mastermind) for the HP-35s/33s

This program is by Bill Harrington and is used here by permission.

This program is supplied without representation or warranty of any kind. Bill Harrington and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

Cows and Bulls is a games where the player trys to guess an x digit random integer with feedback for each guess indicting how many correct digits in the correct location (Bulls) and correct digits in the wrong location (Cows). The score is given as Bulls.Cows, eg. If the secret number is 12325, a guess of 43321 would score 2.1

To play, enter the length of the number 'L' in digits and then successive guesses 'G'. Your score 'S' is calculated for each guess.

Listing

Number = N (eg. 0.nnnn), M, V, A
Length = L (eg. 4)
Guess = G, U, B
Score = S

C001    Lbl C
C002    INPUT L
C003    RAND; STO N
C005    INPUT G
C006    RCL L; STO X; 10x; STO ÷ G
C010    0; STO S,T,U,V
C015    RCL N; STO M
C017    10; STO × M; STO × G
C020    RCL M; IP; STO A
C023    RCL M; FP; STO M
C026    RCL G; IP; STO B
C029    RCL G; FP; STO G
C032    RCL A; RCL B; 
C034    X=Y; GTO C043
C036      STO + U; R↓; STO + V
C039      10; STO ÷ V; STO ÷ U
C042      GTO C045
C043    1; STO + S
C045    Dse X; GTO C017

C047    RCL U; STO G
C049    RCL L; RCL S; -; STO X
C053    X=0; GTO C101
C055      RCL V; STO M; 0; STO V
C059      10; STO × G; RCL G; 
C062      IP; STO B
C064      RCL G; FP; STO G
C067      RCL L,S,-;T; -; STO Y
C073        10; STO × M
C075        RCL M; IP; STO A
C078        RCL M; FP; STO M
C081        RCL B; RCL A
C083        X=Y; GTO C089
C085          STO + V; 10; STO ÷ V
C088          GTO C093
C089        1; STO + T; -/+; STO B
C093      Dse Y; GTO C073
C095    Dse X; GTO C055
C097    RCL T; 10; ÷; STO + S
C101    VIEW S; GTO C005

To run:

XEQ C001
L? <enter the length for the number, eg 4 digits>
R/S
G? <enter you guess for the number>
R/S
S= <your score Bulls.Cows, eg 1.2 means one digit in the
    correct location and 2 digits in the wrong location>
R/S
G? <enter you next guess>

Notes:
IP = Integer Part of a number.
FP = Fraction Part of a number
O; STO S,T,U,V means: 0; STO S; STO T; STOU; STO U; STO v.

Go back to the software library
Go back to the main exhibit hall