Pascal's triangle/Puzzle: Difference between revisions
Content added Content deleted
(Add Factor example) |
|||
Line 1,118: | Line 1,118: | ||
{{out}} |
{{out}} |
||
<pre>x = 5.000000, Y = 13.000000, Z = 8.000000</pre> |
<pre>x = 5.000000, Y = 13.000000, Z = 8.000000</pre> |
||
=={{header|Factor}}== |
|||
<lang factor>USING: arrays backtrack combinators.extras fry grouping.extras |
|||
interpolate io kernel math math.ranges sequences ; |
|||
IN: rosetta-code.pascals-triangle-puzzle |
|||
: base ( ?x ?z -- seq ) 2dup + swap '[ _ 11 _ 4 _ ] >array ; |
|||
: up ( seq -- seq' ) [ [ + ] 2clump-map ] twice ; |
|||
: find-solution ( -- x z ) |
|||
10 [1,b] dup [ amb-lazy ] bi@ 2dup base |
|||
up dup first 40 = must-be-true |
|||
up first 151 = must-be-true ; |
|||
find-solution [I X = ${1}, Z = ${}I] nl</lang> |
|||
{{out}} |
|||
<pre> |
|||
X = 5, Z = 8 |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |