(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 4296, 130] NotebookOptionsPosition[ 3902, 111] NotebookOutlinePosition[ 4243, 126] CellTagsIndexPosition[ 4200, 123] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Three-Card Swindle", "Section", CellChangeTimes->{{3.46219946970787*^9, 3.462199478711334*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"trials", " ", "=", " ", "25000"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"matches", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"cards", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", " ", "=", " ", "1"}], ",", " ", RowBox[{"i", " ", "\[LessEqual]", " ", "trials"}], ",", " ", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"Choose", " ", "a", " ", "random", " ", "card", " ", "1"}], "=", "RR"}], ",", " ", RowBox[{"2", "=", "RB"}], ",", " ", RowBox[{"3", "=", "BB"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"card", " ", "=", " ", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "3"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"side", " ", "=", " ", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "2"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ "cards", "\[LeftDoubleBracket]", "card", "\[RightDoubleBracket]"}], "\[LeftDoubleBracket]", "side", "\[RightDoubleBracket]"}], "\[Equal]", " ", RowBox[{ RowBox[{ "cards", "\[LeftDoubleBracket]", "card", "\[RightDoubleBracket]"}], " ", "\[LeftDoubleBracket]", RowBox[{ RowBox[{"Abs", "[", RowBox[{"side", "-", "2"}], "]"}], "+", "1"}], "\[RightDoubleBracket]"}]}], ",", " ", RowBox[{"matches", "++"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", " ", "matches", ",", " ", "\"\< matches of \>\"", ",", "trials", ",", " ", "\"\< attempts: \>\"", ",", RowBox[{"100", "*", RowBox[{"N", "[", RowBox[{ RowBox[{"matches", "/", "trials"}], ",", "3"}], "]"}]}], ",", "\"\<%\>\""}], "]"}]}], "Input", CellChangeTimes->{{3.46219851857075*^9, 3.462198553128924*^9}, { 3.462198617313595*^9, 3.462198678417179*^9}, {3.462198773573335*^9, 3.462198778406421*^9}, {3.462198812371215*^9, 3.46219902970644*^9}, { 3.462199218271461*^9, 3.462199427993153*^9}, {3.4622765521308327`*^9, 3.4622765807875633`*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Total \"\>", "\[InvisibleSpace]", "16699", "\[InvisibleSpace]", "\<\" matches of \"\>", "\[InvisibleSpace]", "25000", "\[InvisibleSpace]", "\<\" attempts: \"\>", "\[InvisibleSpace]", "66.79599999999999999999999999999999999996`3.", "\[InvisibleSpace]", "\<\"%\"\>"}], SequenceForm[ "Total ", 16699, " matches of ", 25000, " attempts: ", 66.8`3., "%"], Editable->False]], "Print", CellChangeTimes->{{3.462276538847972*^9, 3.462276588847731*^9}}] }, Open ]] }, Open ]] }, WindowSize->{640, 623}, WindowMargins->{{150, Automatic}, {Automatic, 52}}, FrontEndVersion->"7.0 for Mac OS X x86 (32-bit) (November 10, 2008)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[567, 22, 102, 1, 67, "Section"], Cell[CellGroupData[{ Cell[694, 27, 2662, 68, 178, "Input"], Cell[3359, 97, 515, 10, 20, "Print"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)