(***********************************************************************
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[ 7686, 247]*)
(*NotebookOutlinePosition[ 8783, 282]*)
(* CellTagsIndexPosition[ 8739, 278]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[CellGroupData[{
Cell[TextData["Project 2"], "Title",
Evaluatable->False,
AspectRatioFixed->True],
Cell["Last revision: January 27 1999", "SmallText",
Evaluatable->False,
AspectRatioFixed->True],
Cell[CellGroupData[{
Cell["Author: YourNameGoesHere", "Subtitle",
CellFrame->True,
Evaluatable->False,
AspectRatioFixed->True,
Background->GrayLevel[0.899992]],
Cell[CellGroupData[{
Cell[TextData["Lots of Lists"], "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 (or \
method) 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 parts of \
the programming task."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[CellGroupData[{
Cell[TextData["Part A: Individually Pledged"], "Subsection",
Evaluatable->False,
AspectRatioFixed->True],
Cell["\<\
If you choose to do Part B with a partner, turn Part A in \
separately, with the pledge written out in the notebook if submitted \
electronically.\
\>", "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"1. Write a function \"",
StyleBox["combineFactors", "Input",
FontWeight->"Plain"],
"\" which performs the opposite of the ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" function \"",
StyleBox["FactorInteger", "Input",
FontWeight->"Plain"],
"\". For example, ",
StyleBox["1500=(2^2)*3*(5^3)", "Input",
FontWeight->"Plain"],
", so \"",
StyleBox["FactorInteger[1500]", "Input",
FontWeight->"Plain"],
"\" returns \"",
StyleBox["{{2,2},{3,1},{5,3}}", "Input",
FontWeight->"Plain"],
"\"; similarly, \"",
StyleBox["combineFactors[{{2,2},{3,1},{5,3}}]", "Input",
FontWeight->"Plain"],
"\" should return the ",
StyleBox["Integer", "Input",
FontWeight->"Plain"],
" ",
StyleBox["1500", "Input",
FontWeight->"Plain"],
StyleBox[".",
FontWeight->"Plain"]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"2. Recall that Pascal's Triangle looks like this:\n",
StyleBox[" 1\n 1 1\n 1 2 1\n 1 3 3 1", "Input",
FontWeight->"Plain"],
"\n and so on; each row is one longer than the one before, and successive \
entries (except the ",
StyleBox["1", "Input",
FontWeight->"Plain"],
"'s on the end) are given by consecutive sums of entries on the preceding \
row.\n \nWrite a function \"",
StyleBox["pascal[ ]", "Input",
FontWeight->"Plain"],
"\" which has as its argument an ",
StyleBox["Integer",
FontFamily->"Courier"],
" indicating how many rows the user would like and outputs that many rows \
of Pascal's Triangle. \n\nFor example, \"",
StyleBox["pascal[4]", "Input",
FontWeight->"Plain"],
"\" would produce the (nested) list \"",
StyleBox["{{1}, {1,1}, {1,2,1}, {1,3,3,1}}", "Input",
FontWeight->"Plain"],
"\".\n\nGenerate the triangle by addition; do not use the function \"",
StyleBox["Binomial[ ]", "Input",
FontWeight->"Plain"],
"\"."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True]
}, Closed]],
Cell[CellGroupData[{
Cell[TextData[
"Part B: Individually Pledged OR Pledged with One Partner"], "Subsection",
Evaluatable->False,
AspectRatioFixed->True],
Cell["\<\
If you choose to do Part B with a partner, turn in Part B \
separately with the pledge for both partners written out in the \
notebook.\
\>", "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"3. A permutation of length \"",
StyleBox["n", "Input",
FontWeight->"Plain"],
"\" is a list of the first ",
StyleBox["n", "Input",
FontWeight->"Plain"],
" positive integers in some order. Example: ",
StyleBox["{6,1,5,3,4,2}", "Input",
FontWeight->"Plain"],
" is a permutation of length 6. A permutation is called balanced if the \
sum of each consecutive pair is equal to the sum of the consecutive pair \
furthest away from the original pair, if we imagine the permutation written \
in a circle. For instance, (6,1) and (3,4) are pairs furthest away in the \
example above, because they are both 1 unit away from the original pair. \
Similarly, (2,6) and (5,3) are furthest apart. Our example is balanced \
because pairs furthest apart have the same sum: ",
StyleBox["6+1=3+4; 1+5 =4+2; 5+3=2+6; 3+4=6+1; 4+2=1+5; 2+6=5+3", "Input",
FontWeight->"Plain"],
". Another way to see this is to write the consecutive sums in order \
(7,6,8,7,6,8) and notice that the corresponding sums are the furthest apart. \
Note that all of this makes sense only if the length of the permutation (n) \
is even."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"(a) Write a function \"",
StyleBox["balancedQ[ ]", "Input",
FontWeight->"Plain"],
"\" which takes one argument which is a list of even length and returns ",
StyleBox["True", "Input",
FontWeight->"Plain"],
" if it is balanced, ",
StyleBox["False", "Input",
FontWeight->"Plain"],
" otherwise."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"(b) The ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" function \"",
StyleBox["Permutations[]", "Input",
FontWeight->"Plain"],
"\" returns all possible permutations of the elements of a list. Use \"",
StyleBox["Permutations[]", "Input",
FontWeight->"Plain"],
"\" and your function \"",
StyleBox["balancedQ[]", "Input",
FontWeight->"Plain"],
"\" to find all balanced permutations of the numbers ",
StyleBox["{1,2,3,4,5,6}", "Input",
FontWeight->"Plain"],
"."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True]
}, Closed]]
}, Open ]]
}, Open ]]
}, Open ]]
},
FrontEndVersion->"4.0 for Macintosh",
ScreenRectangle->{{0, 1152}, {0, 850}},
WindowToolbars->"EditBar",
WindowSize->{520, 509},
WindowMargins->{{Automatic, 84}, {30, Automatic}},
PrintingCopies->1,
PrintingPageRange->{1, Automatic},
PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}},
ShowCellLabel->True,
ShowCellTags->False,
RenderingOptions->{"ObjectDithering"->True,
"RasterDithering"->False},
MacintoshSystemPageSetup->"\<\
00<0004/0B`000003809T?o>old"
]
(***********************************************************************
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, 100, 2, 26, "SmallText",
Evaluatable->False],
Cell[CellGroupData[{
Cell[1951, 61, 146, 4, 77, "Subtitle",
Evaluatable->False],
Cell[CellGroupData[{
Cell[2122, 69, 90, 2, 50, "Section",
Evaluatable->False],
Cell[2215, 73, 500, 11, 160, "Text",
Evaluatable->False],
Cell[CellGroupData[{
Cell[2740, 88, 109, 2, 46, "Subsection",
Evaluatable->False],
Cell[2852, 92, 218, 6, 46, "Text",
Evaluatable->False],
Cell[3073, 100, 900, 32, 83, "Text",
Evaluatable->False],
Cell[3976, 134, 1077, 28, 254, "Text",
Evaluatable->False]
}, Closed]],
Cell[CellGroupData[{
Cell[5090, 167, 138, 3, 30, "Subsection",
Evaluatable->False],
Cell[5231, 172, 207, 6, 46, "Text",
Evaluatable->False],
Cell[5441, 180, 1212, 25, 174, "Text",
Evaluatable->False],
Cell[6656, 207, 394, 13, 46, "Text",
Evaluatable->False],
Cell[7053, 222, 581, 19, 64, "Text",
Evaluatable->False]
}, Closed]]
}, Open ]]
}, Open ]]
}, Open ]]
}
]
*)
(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)