Pascal's triangle/Puzzle: Difference between revisions

Content added Content deleted
(→‎{{header|Picat}}: Split into subsections)
Line 2,230: Line 2,230:
Below are three different approaches using constraint modelling (cp solver).
Below are three different approaches using constraint modelling (cp solver).


===Using lists to represent the triangle===
{{trans|Prolog}}
{{trans|Prolog}}
<lang Picat>import cp.
<lang Picat>import cp.
Line 2,271: Line 2,272:
[x = 5,y = 13,z = 8]</pre>
[x = 5,y = 13,z = 8]</pre>


===Calculating the positions===
Here is a contraint model which calculates the positions in the triangle that should be added together.
Here is a constraint model which calculates the positions in the triangle that should be added together.
<lang Picat>import cp.
<lang Picat>import cp.


Line 2,324: Line 2,326:
<pre>[x = 5,y = 13,z = 8]</pre>
<pre>[x = 5,y = 13,z = 8]</pre>


And then a version with hard coded constraints:
===Hard coded constraints===
<lang Picat>import cp.
<lang Picat>import cp.


Line 2,361: Line 2,363:
{{out}}
{{out}}
<pre>[x = 5,y = 13,z = 8]</pre>
<pre>[x = 5,y = 13,z = 8]</pre>



=={{header|PicoLisp}}==
=={{header|PicoLisp}}==