(***********************************************************************
Mathematica-Compatible Notebook
This notebook can be used on any computer system with Mathematica 4.0,
MathReader 4.0, or any compatible application. The data for the notebook
starts with the line containing stars above.
To get the notebook into a Mathematica-compatible application, do one of
the following:
* Save the data starting with the line of stars above into a file
with a name ending in .nb, then open the file inside the application;
* Copy the data starting with the line of stars above to the
clipboard, then use the Paste menu command inside the application.
Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode. Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).
NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the
word CacheID, otherwise Mathematica-compatible applications may try to
use invalid cache data.
For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
web: http://www.wolfram.com
email: info@wolfram.com
phone: +1-217-398-0700 (U.S.)
Notebook reader applications are available free of charge from
Wolfram Research.
***********************************************************************)
(*CacheID: 232*)
(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[ 8971, 302]*)
(*NotebookOutlinePosition[ 10059, 337]*)
(* CellTagsIndexPosition[ 10015, 333]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[CellGroupData[{
Cell[TextData["Project 3"], "Title",
Evaluatable->False,
AspectRatioFixed->True],
Cell["Last revision: February 18 1998", "SmallText",
Evaluatable->False,
AspectRatioFixed->True],
Cell[CellGroupData[{
Cell["Author: YourNameHere", "Subtitle",
CellFrame->True,
Evaluatable->False,
AspectRatioFixed->True,
Background->GrayLevel[0.899992]],
Cell[CellGroupData[{
Cell["MasterMind", "Section",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"General suggestions:\n\n(a) Make sure you know how to do a simple example \
by hand.\n\n(b) With scratch work (not on computer), develop an algorithm \
which has steps you think ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" can accomplish. Think in terms of rows, or entire lists.\n\n(c) Use \
bottom-up analysis, defining and testing functions as you build up solutions \
to parts of the programming task."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[CellGroupData[{
Cell[TextData[
"Individually Pledged OR Pledged with One Partner"], "Subsection",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["Your task is to write ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
" code to play the game MasterMind with the computer as the codemaker. \
Your ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[" notebook should define two functions \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["createCode",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" and \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["tryGuess",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\" and should display two example games. Details about the game and the \
functions are given below. As always, use good programming style, strive for \
clarity, and add comments or text to explain anything that might seem \
unclear. ",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["The game of MasterMind centers around a hidden code. This code \
consists of four characters chosen randomly from the set ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["{\"G\", \"B\", \"R\", \"P\", \"Y\", \"W\"}",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[". (In the physical game, objects have the colors green, blue, \
red, purple, yellow, and white, from which our characters are derived.) \
Repeating two or more characters in the hidden code is allowed. ",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox[
"For the player, the object of the game is to guess the code. The player \
is allowed to make guesses of four characters and receives some information \
back for each guess. This information is a list of two integers, the first \
of which is commonly referred to as the number of bulls, the second the \
number of cows. A ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["bull",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
" is a guessed character which does occur in the code at the same position \
as it does in the guess---in other words, a perfect answer for that position \
in the code. A ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["cow",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
" is a guessed character which does occur in the code, but in a different \
position from its position in the guess. ",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["Your function \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["createCode[]",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\" should set the global variable \"hidden\" to some code chosen randomly, \
and the function should not display the code on the screen. Note that this \
operation should be a so-called \"side effect\", since the variable \
\"hidden\" should not be local, lest the game never start.",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["Your function \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["tryGuess[]",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\" should take a string which has four characters in it, determine the \
number of bulls and cows, and return these numbers as a list.",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox[
"As an example, here is an example run, supposing that \"createCode\" has \
defined \"hidden\" to be ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["{\"W\", \"G\", \"W\", \"R\"}",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[":",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[CellGroupData[{
Cell[TextData["tryGuess[\"RWWY\"]"], "Input",
AspectRatioFixed->True],
Cell[TextData["{1, 2}"], "Output",
Evaluatable->False,
AspectRatioFixed->True]
}, Open ]],
Cell[CellGroupData[{
Cell[TextData["tryGuess[\"RWWW\"]"], "Input",
AspectRatioFixed->True],
Cell[TextData["{1, 2}"], "Output",
Evaluatable->False,
AspectRatioFixed->True]
}, Open ]],
Cell[CellGroupData[{
Cell[TextData["tryGuess[\"RWGY\"]"], "Input",
AspectRatioFixed->True],
Cell[TextData["{0, 3}"], "Output",
Evaluatable->False,
AspectRatioFixed->True]
}, Open ]],
Cell[TextData[{
StyleBox[
"Hint: Determining the number of cows is not as simple as it might seem at \
first glance. The total number of bulls and cows matching a character (say ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["\"W\"",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
") is either one of two numbers, the number of such characters in the \
hidden code, or the number of such characters in the guess, whichever is ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["smaller",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
". Hence, one strategy would be to find the total number of bulls and cows, \
then to find the number of bulls, and finally to subtract to find the number \
of cows.",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True]
}, Open ]]
}, Open ]]
}, Open ]]
}, Open ]]
},
FrontEndVersion->"4.0 for Macintosh",
ScreenRectangle->{{0, 832}, {0, 604}},
WindowToolbars->{},
WindowSize->{764, 577},
WindowMargins->{{-2, Automatic}, {Automatic, 1}},
PrintingCopies->1,
PrintingPageRange->{1, Automatic},
PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}},
ShowCellLabel->True,
ShowCellTags->False,
RenderingOptions->{"ObjectDithering"->True,
"RasterDithering"->False},
MacintoshSystemPageSetup->"\<\
00<0004/0B`000002n88o?mooh<E0000000000060801T1T000000`0000
00000000004000000000000000000000\>"
]
(***********************************************************************
Cached data follows. If you edit this Notebook file directly, not using
Mathematica, you must remove the line containing CacheID at the top of
the file. The cache data will then be recreated when you save this file
from within Mathematica.
***********************************************************************)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[1739, 51, 84, 2, 98, "Title",
Evaluatable->False],
Cell[1826, 55, 101, 2, 26, "SmallText",
Evaluatable->False],
Cell[CellGroupData[{
Cell[1952, 61, 142, 4, 77, "Subtitle",
Evaluatable->False],
Cell[CellGroupData[{
Cell[2119, 69, 77, 2, 50, "Section",
Evaluatable->False],
Cell[2199, 73, 500, 11, 144, "Text",
Evaluatable->False],
Cell[CellGroupData[{
Cell[2724, 88, 129, 3, 46, "Subsection",
Evaluatable->False],
Cell[2856, 93, 1222, 40, 64, "Text",
Evaluatable->False],
Cell[4081, 135, 675, 16, 62, "Text",
Evaluatable->False],
Cell[4759, 153, 1092, 30, 98, "Text",
Evaluatable->False],
Cell[5854, 185, 619, 17, 62, "Text",
Evaluatable->False],
Cell[6476, 204, 468, 15, 46, "Text",
Evaluatable->False],
Cell[6947, 221, 437, 15, 30, "Text",
Evaluatable->False],
Cell[CellGroupData[{
Cell[7409, 240, 71, 1, 27, "Input"],
Cell[7483, 243, 82, 2, 26, "Output",
Evaluatable->False]
}, Open ]],
Cell[CellGroupData[{
Cell[7602, 250, 71, 1, 27, "Input"],
Cell[7676, 253, 82, 2, 26, "Output",
Evaluatable->False]
}, Open ]],
Cell[CellGroupData[{
Cell[7795, 260, 71, 1, 27, "Input"],
Cell[7869, 263, 82, 2, 26, "Output",
Evaluatable->False]
}, Open ]],
Cell[7966, 268, 953, 28, 80, "Text",
Evaluatable->False]
}, Open ]]
}, Open ]]
}, Open ]]
}, Open ]]
}
]
*)
(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)