Cell[CellGroupData[{Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"ss", "[", RowBox[{"k2_", ",", "nn_"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"cel", ",", RowBox[{"kk", "=", "k2"}], ",", "a"}], "}"}], ",", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"cel", "[", RowBox[{"1", ",", "n1"}], "]"}], "=", RowBox[{"If", "[", RowBox[{ RowBox[{"n1", "==", RowBox[{"nn", "+", "1"}]}], ",", "1", ",", "0"}], "]"}]}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", RowBox[{ RowBox[{"2", "nn"}], "+", "1"}]}], "}"}]}], "]"}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"cel", "[", RowBox[{"n1", ",", RowBox[{"nn", "+", "2", "-", "n1"}]}], "]"}], "=", RowBox[{"Floor", "[", RowBox[{ RowBox[{"(", RowBox[{"n1", "+", "kk", "-", "1"}], ")"}], "/", "kk"}], "]"}]}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", "nn"}], "}"}]}], "]"}], ";", "\n", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"cel", "[", RowBox[{"n1", ",", RowBox[{"nn", "+", "n1"}]}], "]"}], "=", "1"}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", "nn"}], "}"}]}], "]"}], ";", "\n", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"cel", "[", RowBox[{"n1", ",", "1"}], "]"}], "=", "0"}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", RowBox[{"nn", "-", "1"}]}], "}"}]}], "]"}], ";", "\n", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"cel", "[", RowBox[{"n1", ",", RowBox[{ RowBox[{"2", "nn"}], "+", "1"}]}], "]"}], "=", "0"}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", RowBox[{"nn", "-", "1"}]}], "}"}]}], "]"}], ";", "\n", RowBox[{ RowBox[{"cel", "[", RowBox[{"n1_", ",", "m_"}], "]"}], ":=", RowBox[{ RowBox[{"cel", "[", RowBox[{"n1", ",", "m"}], "]"}], "=", RowBox[{ RowBox[{"cel", "[", RowBox[{ RowBox[{"n1", "-", "1"}], ",", RowBox[{"m", "-", "1"}]}], "]"}], "+", RowBox[{"cel", "[", RowBox[{ RowBox[{"n1", "-", "1"}], ",", RowBox[{"m", "+", "1"}]}], "]"}]}]}]}], ";", "\n", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", RowBox[{ RowBox[{"2", "nn"}], "+", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", RowBox[{ RowBox[{"Floor", "[", RowBox[{ RowBox[{"(", "nn", ")"}], "/", "2"}], "]"}], "+", "3"}]}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"cel", "[", RowBox[{"n1", ",", "m"}], "]"}], ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", RowBox[{ RowBox[{"2", "nn"}], "+", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", RowBox[{"nn", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", RowBox[{ RowBox[{"2", "nn"}], "+", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"n1", ",", "1", ",", RowBox[{ RowBox[{"Floor", "[", RowBox[{ RowBox[{"(", "nn", ")"}], "/", "2"}], "]"}], "+", "3"}]}], "}"}]}], "]"}]}], "]"}]}]}], "]"}]}], ";", RowBox[{ RowBox[{"sh", "[", RowBox[{"p2_", ",", "n2_", ",", "m2_", ",", "v2_"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"t2", ",", "u"}], "}"}], ",", RowBox[{ RowBox[{"t2", "=", RowBox[{"IntegerPart", "[", RowBox[{ RowBox[{"(", RowBox[{"1", "+", "p2", "-", "m2", "+", "n2", "-", "v2"}], ")"}], "/", "p2"}], "]"}]}], ";", RowBox[{"u", "=", RowBox[{"(", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"z", "=", "0"}], RowBox[{"t2", "-", "1"}]], RowBox[{"Binomial", "[", RowBox[{ RowBox[{"n2", "-", "v2", "-", RowBox[{"p2", "*", "z"}]}], ",", RowBox[{"m2", "-", "1"}]}], "]"}]}], ")"}]}]}]}], "]"}]}], ";"}], " ", RowBox[{ RowBox[{"tri2", "[", RowBox[{"t_", ",", "nn_", ",", "k_"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"s", ",", "mm"}], "}"}], ",", RowBox[{ RowBox[{"mm", "=", RowBox[{"t", "/", "50"}]}], ";", " ", RowBox[{"s", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"sh", "[", RowBox[{"nn", ",", "n", ",", "m", ",", "1"}], "]"}], ",", "k"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "t"}], "}"}], ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";", RowBox[{"Graphics", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"Join", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"1", ",", "1", ",", "1"}], "]"}], ",", RowBox[{"Polygon", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0.3", ",", "0.3"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "25.4"}], "mm"}], ",", RowBox[{ RowBox[{"-", "50.7"}], "mm"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"25.9", "mm"}], ",", RowBox[{ RowBox[{"-", "50.7"}], "mm"}]}], "}"}]}], "}"}], "]"}]}], "}"}], ",", "\n", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Hue", "[", RowBox[{ RowBox[{"(", RowBox[{"6", "+", RowBox[{"s", "[", RowBox[{"[", RowBox[{"x", ",", "y"}], "]"}], "]"}]}], ")"}], "/", "4"}], "]"}], ",", RowBox[{"Text", "[", RowBox[{ RowBox[{"s", "[", RowBox[{"[", RowBox[{"x", ",", "y"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"-", "0.5"}], "x"}], "+", "y"}], ",", RowBox[{"-", "x"}]}], "}"}]}], "]"}]}], "}"}], ",", "\n", RowBox[{"{", RowBox[{"x", ",", "1", ",", "t"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "1", ",", "x"}], "}"}]}], "]"}]}], "]"}], "]"}], ",", RowBox[{"AspectRatio", "->", "Automatic"}], ",", RowBox[{"ImageSize", "->", RowBox[{"{", RowBox[{"400", ",", "400"}], "}"}]}], ",", RowBox[{"Background", "->", "Black"}]}], "]"}]}]}], "]"}]}]}], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, {3.399371801238434*^9, 3.3993718013165827`*^9}, {3.3996349203764944`*^9, 3.3996349424701033`*^9}, {3.3996405445748744`*^9, 3.399640551465455*^9}, 3.3996406047151146`*^9, 3.3996406389961452`*^9, 3.760768854321376*^9}, CellID->699097317], Cell[BoxData[ RowBox[{"Manipulate", "[", " ", RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"pp", ">", "n"}], ",", RowBox[{"pp", "=", "n"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"se", "==", "1"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{ RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{"#", ",", "k"}], "]"}], "&"}], ",", RowBox[{"ss", "[", RowBox[{"pp", ",", "n"}], "]"}]}], "]"}], ",", RowBox[{"ColorRules", "->", RowBox[{"{", RowBox[{ RowBox[{"1", "->", RowBox[{"Hue", "[", "0.6", "]"}]}], ",", RowBox[{"2", "->", RowBox[{"Hue", "[", "0.8", "]"}]}], ",", RowBox[{"3", "->", RowBox[{"Hue", "[", "0.4", "]"}]}], ",", RowBox[{"4", "->", RowBox[{"Hue", "[", "0.2", "]"}]}], ",", RowBox[{"5", "->", RowBox[{"Hue", "[", "0.9", "]"}]}], ",", RowBox[{"6", "->", RowBox[{"Hue", "[", "1.0", "]"}]}], ",", RowBox[{"_", "->", "White"}]}], "}"}]}], ",", RowBox[{"Frame", "->", "False"}], ",", RowBox[{"ImageSize", "->", RowBox[{"{", RowBox[{"400", ",", "400"}], "}"}]}]}], "]"}], ",", RowBox[{"tri2", "[", RowBox[{"n", ",", "pp", ",", "k"}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"se", ",", "1", ",", "\"\<\>\""}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"1", "->", "\"\\""}], ",", RowBox[{"2", "->", "\"\\""}]}], "}"}], ",", RowBox[{"ImageSize", "->", "Tiny"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"pp", ",", "3", ",", "\"\\""}], "}"}], ",", "2", ",", "n", ",", "1", ",", RowBox[{"ImageSize", "->", "Tiny"}], ",", RowBox[{"Appearance", "->", "\"\\""}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"k", ",", "3", ",", "\"\\""}], "}"}], ",", "2", ",", "7", ",", "1", ",", RowBox[{"ImageSize", "->", "Tiny"}], ",", RowBox[{"Appearance", "->", "\"\\""}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"n", ",", "30", ",", "\"\\""}], "}"}], ",", "20", ",", "50", ",", "1", ",", RowBox[{"ImageSize", "->", "Tiny"}], ",", RowBox[{"Appearance", "->", "\"\\""}]}], "}"}], ",", RowBox[{"SaveDefinitions", "->", "True"}], ",", RowBox[{"ControlPlacement", "->", "Left"}]}], "]"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, 3.3993667998258*^9, {3.399376927717515*^9, 3.3993769393303823`*^9}, {3.399376998176203*^9, 3.3993770192762976`*^9}, 3.760768854317848*^9}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`k$$ = 3, $CellContext`n$$ = 30, $CellContext`pp$$ = 3, $CellContext`se$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`se$$], 1, ""}, { 1 -> "arrays", 2 -> "numbers"}}, {{ Hold[$CellContext`pp$$], 3, "players"}, 2, Dynamic[$CellContext`n$$], 1}, {{ Hold[$CellContext`k$$], 3, "modulus"}, 2, 7, 1}, {{ Hold[$CellContext`n$$], 30, "rows"}, 20, 50, 1}}, Typeset`size$$ = {400., {198., 202.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`se$222129$$ = False, $CellContext`pp$222130$$ = 0, $CellContext`k$222131$$ = 0, $CellContext`n$222132$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`k$$ = 3, $CellContext`n$$ = 30, $CellContext`pp$$ = 3, $CellContext`se$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`se$$, $CellContext`se$222129$$, False], Hold[$CellContext`pp$$, $CellContext`pp$222130$$, 0], Hold[$CellContext`k$$, $CellContext`k$222131$$, 0], Hold[$CellContext`n$$, $CellContext`n$222132$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> ( If[$CellContext`pp$$ > $CellContext`n$$, $CellContext`pp$$ = \ $CellContext`n$$]; If[$CellContext`se$$ == 1, ArrayPlot[ Map[Mod[#, $CellContext`k$$]& , $CellContext`ss[$CellContext`pp$$, $CellContext`n$$]], ColorRules -> { 1 -> Hue[0.6], 2 -> Hue[0.8], 3 -> Hue[0.4], 4 -> Hue[0.2], 5 -> Hue[0.9], 6 -> Hue[1.], Blank[] -> White}, Frame -> False, ImageSize -> {400, 400}], $CellContext`tri2[$CellContext`n$$, $CellContext`pp$$, \ $CellContext`k$$]]), "Specifications" :> {{{$CellContext`se$$, 1, ""}, { 1 -> "arrays", 2 -> "numbers"}, ImageSize -> Tiny}, {{$CellContext`pp$$, 3, "players"}, 2, Dynamic[$CellContext`n$$], 1, ImageSize -> Tiny, Appearance -> "Labeled"}, {{$CellContext`k$$, 3, "modulus"}, 2, 7, 1, ImageSize -> Tiny, Appearance -> "Labeled"}, {{$CellContext`n$$, 30, "rows"}, 20, 50, 1, ImageSize -> Tiny, Appearance -> "Labeled"}}, "Options" :> {ControlPlacement -> Left}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{608., {227., 233.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`ss[ Pattern[$CellContext`k2, Blank[]], Pattern[$CellContext`nn, Blank[]]] := Block[{$CellContext`cel, $CellContext`kk = $CellContext`k2, \ $CellContext`a}, Table[$CellContext`cel[1, $CellContext`n1] = If[$CellContext`n1 == $CellContext`nn + 1, 1, 0], {$CellContext`n1, 1, 2 $CellContext`nn + 1}]; Table[$CellContext`cel[$CellContext`n1, $CellContext`nn + 2 - $CellContext`n1] = Floor[($CellContext`n1 + $CellContext`kk - 1)/$CellContext`kk], {$CellContext`n1, 1, $CellContext`nn}]; Table[$CellContext`cel[$CellContext`n1, $CellContext`nn + \ $CellContext`n1] = 1, {$CellContext`n1, 1, $CellContext`nn}]; Table[$CellContext`cel[$CellContext`n1, 1] = 0, {$CellContext`n1, 1, $CellContext`nn - 1}]; Table[$CellContext`cel[$CellContext`n1, 2 $CellContext`nn + 1] = 0, {$CellContext`n1, 1, $CellContext`nn - 1}]; $CellContext`cel[ Pattern[$CellContext`n1, Blank[]], Pattern[$CellContext`m, Blank[]]] := ($CellContext`cel[$CellContext`n1, \ $CellContext`m] = $CellContext`cel[$CellContext`n1 - 1, $CellContext`m - 1] + $CellContext`cel[$CellContext`n1 - 1, $CellContext`m + 1]); Join[ Table[ Table[ 0, {$CellContext`m, 1, 2 $CellContext`nn + 1}], {$CellContext`n1, 1, Floor[$CellContext`nn/2] + 3}], Table[ Table[ $CellContext`cel[$CellContext`n1, $CellContext`m], \ {$CellContext`m, 1, 2 $CellContext`nn + 1}], {$CellContext`n1, 1, $CellContext`nn - 1}], Table[ Table[ 0, {$CellContext`m, 1, 2 $CellContext`nn + 1}], {$CellContext`n1, 1, Floor[$CellContext`nn/2] + 3}]]], $CellContext`tri2[ Pattern[$CellContext`t$, Blank[]], Pattern[$CellContext`nn$, Blank[]], Pattern[$CellContext`k$, Blank[]]] := Block[{$CellContext`s, $CellContext`mm}, $CellContext`mm = \ $CellContext`t$/50; $CellContext`s = Table[ Mod[ $CellContext`sh[$CellContext`nn$, FE`n$$790, $CellContext`m, 1], $CellContext`k$], { FE`n$$790, 1, $CellContext`t$}, {$CellContext`m, 1, FE`n$$790}]; Graphics[ Evaluate[ Join[{ RGBColor[1, 1, 1], Polygon[{{0.3, 0.3}, {(-25.4) $CellContext`mm, (-50.7) \ $CellContext`mm}, {25.9 $CellContext`mm, (-50.7) $CellContext`mm}}]}, Table[{ Hue[(6 + Part[$CellContext`s, $CellContext`x, \ $CellContext`y])/4], Text[ Part[$CellContext`s, $CellContext`x, $CellContext`y], \ {(-0.5) $CellContext`x + $CellContext`y, -$CellContext`x}]}, \ {$CellContext`x, 1, $CellContext`t$}, {$CellContext`y, 1, $CellContext`x}]]], AspectRatio -> Automatic, ImageSize -> {400, 400}, Background -> Black]], $CellContext`sh[ Pattern[$CellContext`p2, Blank[]], Pattern[$CellContext`n2, Blank[]], Pattern[$CellContext`m2, Blank[]], Pattern[$CellContext`v2, Blank[]]] := Block[{$CellContext`t2, $CellContext`u}, $CellContext`t2 = IntegerPart[( 1 + $CellContext`p2 - $CellContext`m2 + $CellContext`n2 - \ $CellContext`v2)/$CellContext`p2]; $CellContext`u = Sum[ Binomial[$CellContext`n2 - $CellContext`v2 - \ $CellContext`p2 $CellContext`z, $CellContext`m2 - 1], {$CellContext`z, 0, $CellContext`t2 - 1}]], FE`n$$790 = 30}; Typeset`initDone$$ = True), SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{3.760768854318157*^9}, CellID->78672762] }, {3}]]