#!/usr/bin/perl -w
######################
#
# moo.pl
#
# A cute little game in which the user
# tries to guess a number that the computer picks.
#
# This game is also called Mastermind;
# see http://cs.marlboro.edu/code/javascript/mastermind/mastermind.html
# for a javascript version running in a web page.
#
# Version history
#
#   * 0.1_jm  partial program outline created; rest left as an exercise.
#             Jim Mahoney, Sep 15 2003
#
######################
use strict;
my $VERSION = "0.1_jm";    # Change this to a higher number with your initials.
my $DEBUG = 1;             # 1 => print debugging diagnostics; 0 => don't.

print "Let's play a game of *** MOO *** (version $VERSION). \n\n";

# Computer picks 4 randoms from 1..6 and puts them in this array.
my @answer = ();
##  --- your code here ---

# Get user guess (4 digits from 1..6)
print "Guess 4 digits each 1..6 : ";
my $line = <>;                        # Read in a line of input.
chomp($line);                         # Remove the carriage return.
my @guess = split //, $line;          # Split characters into an array.

# Debugging:
print "   DEBUG: guess is @guess \n" if $DEBUG;

# Check to make sure the guess is legal.
##  --- your code here ---

my ($bulls, $cows);
# Count number of 
#   bulls (a digit in @guess matches one in @numbers in same place), and
#   cows  (a digit in @guess matches one anywhere in @numbers).
# You may not count any digit in either @guess or @numbers more than once.
##  --- your code here ---

# Tell the user the result.
print "  '$line' is worth $bulls bulls and $cows cows.\n";

# Add some kind of looping construct around 
# the previous code to allow the user to make multiple guesses.

