Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Content-type: application/vnd.wolfram.cdf.text *)
- (*** Wolfram CDF File ***)
- (* http://www.wolfram.com/cdf *)
- (* CreatedBy='Mathematica 10.0' *)
- (*************************************************************************)
- (* *)
- (* The Mathematica License under which this file was created prohibits *)
- (* restricting third parties in receipt of this file from republishing *)
- (* or redistributing it by any means, including but not limited to *)
- (* rights management or terms of use, without the express consent of *)
- (* Wolfram Research, Inc. For additional information concerning CDF *)
- (* licensing and redistribution see: *)
- (* *)
- (* www.wolfram.com/cdf/adopting-cdf/licensing-options.html *)
- (* *)
- (*************************************************************************)
- (*CacheID: 234*)
- (* Internal cache information:
- NotebookFileLineBreakTest
- NotebookFileLineBreakTest
- NotebookDataPosition[ 1064, 20]
- NotebookDataLength[ 4382, 141]
- NotebookOptionsPosition[ 5046, 141]
- NotebookOutlinePosition[ 5388, 156]
- CellTagsIndexPosition[ 5345, 153]
- WindowFrame->Normal*)
- (* Beginning of Notebook Content *)
- Notebook[{
- Cell[BoxData[{
- RowBox[{
- RowBox[{"SeedRandom", "@",
- RowBox[{"Input", "[", "]"}]}], ";"}], "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"g", "=",
- RowBox[{
- RowBox[{"0", "&"}], "~", "Array", "~",
- RowBox[{"{",
- RowBox[{"109", ",", "109"}], "}"}]}]}], ";"}], "\[IndentingNewLine]",
- RowBox[{
- RowBox[{
- RowBox[{"g", "[",
- RowBox[{"[",
- RowBox[{"2", ",", "2"}], "]"}], "]"}], "=", "1"}],
- ";"}], "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"h", "=",
- RowBox[{"{",
- RowBox[{"{",
- RowBox[{"2", ",", "2"}], "}"}], "}"}]}], ";"}], "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"For", "[",
- RowBox[{
- RowBox[{"n", "=", "1"}], ",",
- RowBox[{"n", "<", "1009"}], ",", "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"c", "=",
- RowBox[{"RandomChoice", "@", "h"}]}], ";", "\[IndentingNewLine]",
- RowBox[{"d", "=",
- RowBox[{"RandomChoice", "[",
- RowBox[{"m", "=",
- RowBox[{"{",
- RowBox[{
- RowBox[{"{",
- RowBox[{"1", ",", "0"}], "}"}], ",",
- RowBox[{"{",
- RowBox[{"0", ",", "1"}], "}"}]}], "}"}]}], "]"}]}], ";",
- "\[IndentingNewLine]",
- RowBox[{"If", "[",
- RowBox[{
- RowBox[{
- RowBox[{"FreeQ", "[",
- RowBox[{
- RowBox[{"e", "=",
- RowBox[{"c", "+", "d"}]}], ",",
- RowBox[{"1", "|", "109"}]}], "]"}], "&&",
- RowBox[{
- RowBox[{"Count", "[",
- RowBox[{
- RowBox[{"g", "[",
- RowBox[{"[",
- RowBox[{
- RowBox[{"2", ";;",
- RowBox[{"e", "[",
- RowBox[{"[", "1", "]"}], "]"}]}], ",",
- RowBox[{"2", ";;",
- RowBox[{"e", "[",
- RowBox[{"[", "2", "]"}], "]"}]}]}], "]"}], "]"}], ",", "0",
- ",", "2"}], "]"}], "\[Equal]", "1"}]}], ",", "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"++", "n"}], ";", "\[IndentingNewLine]",
- RowBox[{"h", "~", "AppendTo", "~", "e"}], ";", "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"g", "[",
- RowBox[{"[",
- RowBox[{
- RowBox[{"##", "&"}], "@@", "e"}], "]"}], "]"}], "=", "1"}]}]}],
- "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}],
- ";"}], "\[IndentingNewLine]",
- RowBox[{
- RowBox[{
- RowBox[{
- RowBox[{"(", "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"c", "=", "#"}], ";", "\[IndentingNewLine]",
- RowBox[{
- RowBox[{
- RowBox[{"If", "[",
- RowBox[{
- RowBox[{
- RowBox[{"e", "=",
- RowBox[{"c", "+", "#"}]}], ";",
- RowBox[{
- RowBox[{"g", "[",
- RowBox[{"[",
- RowBox[{
- RowBox[{"##", "&"}], "@@", "e"}], "]"}], "]"}], "<", "1"}]}],
- ",", "\[IndentingNewLine]",
- RowBox[{
- RowBox[{"g", "[",
- RowBox[{"[",
- RowBox[{
- RowBox[{"##", "&"}], "@@", "e"}], "]"}], "]"}], "=", "2"}]}],
- "\[IndentingNewLine]", "]"}], "&"}], "/@",
- RowBox[{"Join", "@@",
- RowBox[{"{",
- RowBox[{"m", ",",
- RowBox[{"-", "m"}]}], "}"}]}]}]}], ")"}], "&"}], "/@", "h"}],
- ";"}], "\[IndentingNewLine]",
- RowBox[{"ArrayPlot", "[",
- RowBox[{"g", ",",
- RowBox[{"ImageSize", "\[Rule]", "409"}], ",",
- RowBox[{"PixelConstrained", "\[Rule]", "True"}], ",",
- RowBox[{"Frame", "\[Rule]",
- RowBox[{"0", ">", "1"}]}]}], "]"}]}], "Input",
- CellChangeTimes->{{3.621080815817226*^9, 3.6210808199436903`*^9}}]
- },
- WindowSize->{789, 872},
- WindowMargins->{{323, Automatic}, {23, Automatic}},
- FrontEndVersion->"10.0 for Microsoft Windows (64-bit) (July 1, 2014)",
- StyleDefinitions->"Default.nb"
- ]
- (* End of Notebook Content *)
- (* Internal cache information *)
- (*CellTagsOutline
- CellTagsIndex->{}
- *)
- (*CellTagsIndex
- CellTagsIndex->{}
- *)
- (*NotebookFileOutline
- Notebook[{
- Cell[1464, 33, 3578, 106, 392, "Input"]
- }
- ]
- *)
- (* End of internal cache information *)
- (* NotebookSignature 8upZ4aM3#Iq@XAKWpeDJ2TFl *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement