Pascal's triangle/Puzzle: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: (now part of distro))
Line 1,754: Line 1,754:


=={{header|Phix}}==
=={{header|Phix}}==
Converts the pyramid to rules quite nicely, however I will concede
Converts the pyramid to rules quite nicely, <small><del>however I will concede
that solving those two rules (18=2x+z and 73=5x+6z) and specifically converting them
that solving those two rules (18=2x+z and 73=5x+6z) and specifically converting them
into xrule(35=7x) and zrule(56=7z) is somewhat amateurish - suggestions welcome.
into xrule(35=7x) and zrule(56=7z) is somewhat amateurish - suggestions welcome.</del></small>
UPDATE: See [[Solving_coin_problems#Phix]], routine solveN()
<lang Phix>-- demo\rosetta\Pascal_triangle_Puzzle.exw
<lang Phix>-- demo\rosetta\Pascal_triangle_Puzzle.exw
sequence pyramid = {
sequence pyramid = {
Line 1,806: Line 1,807:


-- admittedly this bit is rather amateurish, and maybe problem-specific:
-- admittedly this bit is rather amateurish, and maybe problem-specific:
-- UPDATE: as above, see that solveN() routine.
sequence xrule = sq_sub(sq_mul(rules[1],rules[2][3]),sq_mul(rules[2],rules[1][3])),
sequence xrule = sq_sub(sq_mul(rules[1],rules[2][3]),sq_mul(rules[2],rules[1][3])),
zrule = sq_sub(sq_mul(rules[2],rules[1][2]),sq_mul(rules[1],rules[2][2]))
zrule = sq_sub(sq_mul(rules[2],rules[1][2]),sq_mul(rules[1],rules[2][2]))