Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
n=7;
|
||||
Column[StringReplace[ToString /@ Replace[MatrixExp[SparseArray[
|
||||
{Band[{2,1}] -> Range[n-1]},{n,n}]],{x__,0..}->{x},2] ,{"{"|"}"|","->" "}], Center]
|
||||
19
Task/Pascals-triangle/Mathematica/pascals-triangle-2.math
Normal file
19
Task/Pascals-triangle/Mathematica/pascals-triangle-2.math
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
nmax := 10;
|
||||
pascal[nmax_] := Module[
|
||||
{vals = Table[Binomial[n, k], {n, 0, nmax}, {k, 0, n}],
|
||||
ids = Table[{n, k}, {n, 0, nmax}, {k, 0, n}],
|
||||
labels, left, right, leftright, edgeLabels
|
||||
},
|
||||
labels = Flatten[Thread /@ (Thread[ids -> vals]), 1];
|
||||
left = DeleteCases[Flatten[Flatten[ids, 1] /. {n_, k_} /; (n >= k + 1) :> {{n, k + 1} -> {n + 1, k + 1}}, 1], _?NumberQ];
|
||||
right = DeleteCases[Flatten[Flatten[ids, 1] /. {n_, k_} /; (n > k) :> {{n, k} -> {n + 1, k + 1}}, 1], _?NumberQ];
|
||||
leftright = DeleteCases[left \[Union] right, _ -> {b_, _} /; b > nmax];
|
||||
edgeLabels = (# -> Style["+", Medium] & /@ leftright);
|
||||
Graph[Flatten[ids, 1], leftright
|
||||
, VertexLabels -> MapAt[Placed[#, Center] &, labels, {All, 2}]
|
||||
, GraphLayout -> "SpringEmbedding"
|
||||
, VertexSize -> 0.8, EdgeLabels -> edgeLabels
|
||||
, PlotLabel -> "Pascal's Triangle"
|
||||
]
|
||||
];
|
||||
pascal[nmax]
|
||||
Loading…
Add table
Add a link
Reference in a new issue