(***********************************************************************
Mathematica-Compatible Notebook
This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the notebook
starts with the line of 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[ 9951, 264]*)
(*NotebookOutlinePosition[ 10696, 290]*)
(* CellTagsIndexPosition[ 10652, 286]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[CellGroupData[{
Cell[TextData[{
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[" Pearls",
Evaluatable->False,
AspectRatioFixed->True]
}], "Title",
Evaluatable->False,
AspectRatioFixed->True],
Cell["Problems and Solutions\t\t\t\t\tVol 8 No 1", "Subsubtitle",
Evaluatable->False,
AspectRatioFixed->True],
Cell["by Don Piele", "Subsubtitle",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"Welcome back to Mathematica Pearls, the column devoted to examining \
interesting Mathematica solutions to an assortment of simple and appealing \
problems. \n\nIn the70's and 80's, programming in BASIC or Pascal was a \
common activity for students taking computer classes in school. In the early \
days of the PC, all of the computer magazines and books contained program \
listings inviting the reader to enter and run them. I still have a copy of \
\"What To Do After You Hit Return or P.C.C.'s First Book of Computer Games\" \
by People's Computer Company. It is filled with BASIC code written to play \
number guessing games, word games, \"Nimlike\" games, pattern games, and \
board games. Many of us learned programming by taking the code apart to see \
what made it tick. Unlike the traditional school mathematics problem, the way \
people chose to solve the same programming problem was typically very \
different and very original.\n\nAs a result of this new problem solving \
paradigm, young minds dove full speed into programming and became exceedingly \
good at it. In all other school subjects the same students were never a \
threat. But when it came to computer programming the tables were reversed. It \
is hard to think of another school subject where this has ever happened. \n\n\
In 1981, I organized the first National Computer Problem Solving Competition \
and ran it in Creative Computing magazine. The goal was to create a \
standardized set of computer programming problems to challenge the BASIC \
language abilities of primary and secondary students. There were three \
divisions; Elementary (grades 4-6), Junior (grades 7-9) and Senior (grades \
10-12).The following year it became the International Computer Problem \
Solving Contest (ICPSC). It grew in popularity along with the push to \
introduce computer programming in the schools. It peaked in the late 80's \
when schools shifted from offering programming courses to teaching computer \
literacy. In 1993, it was replaced by the USA Computing Olympiad that selects \
the USA programming team to the annual International Olympiad in Informatics \
(www.usaco.org). What once involved over 5,000 students with a wide range of \
abilities and ages, now focused on the top 200 high school students, mostly \
Juniors and Seniors, who are actively engaged in advanced programming courses \
high school.\n\nSo what does this all have to do with ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" Pearls? Simple. I though it would be fun and educational to see how the \
readers of this magazine would use ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" go about solving a sample set of the same problems that appeared in the \
ICPSC. Let's call it Pearl Harvest I. "
}], "Text"],
Cell[CellGroupData[{
Cell["Pearl Harvest I", "Section"],
Cell[TextData[{
StyleBox["Goals",
FontWeight->"Bold"],
"\n1) Help beginners.\nPearl Harvest I provides a common set of \
programming problems to work on. You may not find the best solution, but can \
you find any solution? In the process of trying to solve these problems, you \
stand the most to gain.\n \n 2) Find the best solution.\n The best solution \
will most likely be found by experienced ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" users. An explanation of the best solutions will help everyone advance \
in their ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" programming skills.\n \n3) Encourage and support programming in ",
StyleBox["Mathematica.\n",
FontSlant->"Italic"],
" ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" is a relatively new programming language that needs encouragement at the \
beginning level. The best way to learn how to advance your skill is to work \
on problems. Our fine community of advanced users is always willing to share \
their ideas. \n\nEmail your solutions to don@piele.com. All ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" solutions, especially from beginners, are welcome. A variety of \
solutions will be presented in ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" Pearls in Vol 8 No. 3. Have fun!\n"
}], "Text"],
Cell[CellGroupData[{
Cell["Unique Quotients ('92)", "Subsection"],
Cell[TextData[{
"Create the function ",
Cell[BoxData[
FormBox[
StyleBox[\(uniqueQuotients[n_\),
FontWeight->"Bold"], TraditionalForm]]],
StyleBox["] ",
FontWeight->"Bold"],
"that finds all solutions to the expression:\n\n\t\t\t\t\t\t",
Cell[BoxData[
FormBox[
FractionBox["ABCDE",
RowBox[{
RowBox[{"FGH", " ",
StyleBox["I",
FontWeight->"Plain",
FontSlant->"Plain",
FontTracking->"Plain",
FontVariations->{"Underline"->False,
"Outline"->False,
"Shadow"->False}], " ", "J"}], " "}]], TraditionalForm]]],
"== n \n\t\t\t\t\t\t\nwhere A,B,C,D,E,F,G,H,I,J are unique digits ( 0 \
through 9) that appear once and only once. Leading zeros are allowed, i.e., \
F can be zero.\n\nOne solution for n= 9, ABCDEFGHIJ = 5742906381"
}], "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell["Zero Sum ('89)", "Subsection"],
Cell[TextData[{
"Create the function ",
StyleBox["zeroSum[n_] ",
FontWeight->"Bold"],
"that finds all solutions to the expression:\n\n\t \
\t1 @ 2 @ 3 @......@n == 0 \n\t \t\nwhere n is a \
single digit and each occurance of @ can be either a (+) or (-) or () which \
means to concatenate the digits.\n\nOne solution for n = 7, 1 - 23 - 45 + 67\
\t \t"
}], "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell["Latin Squares ('83)", "Subsection"],
Cell[TextData[{
"Create the function ",
StyleBox["latinSquares[n_]",
FontWeight->"Bold"],
" that finds all n x n Latin Squares for n<=9. A square matrix of the form\n\
\n\t\t\t\t\t\t",
Cell[BoxData[
FormBox[
RowBox[{" ", GridBox[{
{"1", "2", "3", "4", "5"},
{"2", "1", "4", "5", "3"},
{"3", "4", "5", "1", "2"},
{"4", "5", "2", "3", "1"},
{"5", "3", "1", "2", "4"}
}]}], TraditionalForm]]],
"\n\t\t\t\t\t\t\nis a 5 x 5 Latin Square. Note that each digit appears once \
and only once in each row and column. Since any permuation of the columns is \
a solution, find only the solutions where the first row is the digits 1 2 3 \
... n. \n\nOne solution for n = 5 is shown above.\t\t\t\t\t\t"
}], "Text"],
Cell[CellGroupData[{
Cell["About The Author", "Subsubsection"],
Cell[TextData[{
"Don Piele has been interested in creating programming problems since he \
began the International Computer Problem Solving Contest in the pages of ",
StyleBox["Creative Computing",
FontVariations->{"Underline"->True}],
" in 1981. In 1992, he organized the USA Computing Olympiad (USACO), which \
selects the top four American high school computer programmers to represent \
the USA at the annual International Computing Olympiad. He also writes a \
column, \"",
StyleBox["Cowculations,\" ",
FontSlant->"Italic"],
"in",
StyleBox[" ",
FontSlant->"Italic"],
StyleBox["Quantum Magazine",
FontVariations->{"Underline"->True}],
StyleBox[" ",
FontSlant->"Italic"],
", devoted to computer algorithms using ",
StyleBox["Mathematica",
FontSlant->"Italic"],
". The Web address for the USACO is: http:// www.usaco.org."
}], "Text"]
}, Open ]],
Cell["\<\
Don Piele
Mathematics Department
University of Wisconsin-Parkside
Kenosha, WI 53141
don@piele.com
\
\>", "Subsubsection"]
}, Open ]]
}, Open ]]
}, Open ]]
},
FrontEndVersion->"Microsoft Windows 3.0",
ScreenRectangle->{{0, 1024}, {0, 704}},
WindowSize->{968, 609},
WindowMargins->{{3, Automatic}, {Automatic, 5}},
PrintingCopies->1,
PrintingPageRange->{Automatic, Automatic},
StyleDefinitions -> "Default.nb"
]
(***********************************************************************
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[1731, 51, 254, 10, 105, "Title",
Evaluatable->False],
Cell[1988, 63, 114, 2, 53, "Subsubtitle",
Evaluatable->False],
Cell[2105, 67, 83, 2, 53, "Subsubtitle",
Evaluatable->False],
Cell[2191, 71, 2798, 41, 394, "Text"],
Cell[CellGroupData[{
Cell[5014, 116, 34, 0, 53, "Section"],
Cell[5051, 118, 1354, 31, 299, "Text"],
Cell[CellGroupData[{
Cell[6430, 153, 44, 0, 47, "Subsection"],
Cell[6477, 155, 920, 24, 150, "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell[7434, 184, 36, 0, 47, "Subsection"],
Cell[7473, 186, 447, 9, 147, "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell[7957, 200, 41, 0, 47, "Subsection"],
Cell[8001, 202, 812, 19, 231, "Text"],
Cell[CellGroupData[{
Cell[8838, 225, 41, 0, 43, "Subsubsection"],
Cell[8882, 227, 883, 22, 90, "Text"]
}, Open ]],
Cell[9780, 252, 131, 7, 128, "Subsubsection"]
}, Open ]]
}, Open ]]
}, Open ]]
}
]
*)
(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)