Week 7

  1. In mastermind there are six colours and four pegs. Using 0-5 for the colours, write a program that prints out all possible combinations of the colours.

  2. Generalise this to $n$ colours and $m$ pegs. The $n$ and $m$ should be passed to the program as command line arguments.

  3. Write a program that stores four random integers between 0 and 5 in an array and print out the array.

  4. Write a program that stores $m$ random integers between 0 and $n$ in an array and prints out the array.



s.danicic@gold.ac.uk
Sebastian Danicic BSc MSc PhD (Reader in Computer Science)
Dept of Computing, Goldsmiths, University of London, London SE14 6NW
Last updated 2015-09-04