Pascal's triangle/Puzzle: Difference between revisions

Content added Content deleted
No edit summary
Line 314:
|5 11 13 4 8|
+-----------+</pre>
 
=={{header|Mathematica}}==
We assign a variable to each block starting on top with a, then on the second row b,c et cetera. k,m, and o are replaced by X, Y, and Z. We can write the following equations:
<lang Mathematica>
b+c==a
d+e==b
e+f==c
g+h==d
h+i==e
i+j==f
l+X==g
l+Y==h
n+Y==i
n+Z==j
X+Z==Y
</lang>
And we have the knowns
<lang Mathematica>
a->151
d->40
l->11
n->4
</lang>
Giving us 10 equations with 10 unknowns; i.e. solvable. So we can do so by:
<lang Mathematica>
eqs={a==b+c,d+e==b,e+f==c,g+h==d,h+i==e,i+j==f,l+X==g,l+Y==h,n+Y==i,n+Z==j,Y==X+Z};
knowns={a->151,d->40,l->11,n->4};
Solve[eqs/.knowns,{b,c,e,f,g,h,i,j,X,Y,Z}]
</lang>
gives back:
<lang Mathematica>
{{b -> 81, c -> 70, e -> 41, f -> 29, g -> 16, h -> 24, i -> 17, j -> 12, X -> 5, Y -> 13, Z -> 8}}
</lang>
In pyramid form that would be:
<lang Mathematica>
151
81 70
40 41 29
16 24 17 12
5 11 13 4 8
</lang>
 
=={{header|Oz}}==