Pascal's triangle/Puzzle: Difference between revisions
Added Wren
m (→{{header|Phix}}: pp_StrFmt tweaks) |
(Added Wren) |
||
Line 2,687:
16.0 24.0 17.0 12.0
5.0 11.0 13.0 4.0 8.0</pre>
=={{header|Wren}}==
{{trans|Kotlin}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "/fmt" for Fmt
var isIntegral = Fn.new { |x, tol| x.fraction.abs <= tol }
var pascal = Fn.new { |a, b, mid, top|
var yd = (top - 4 * (a + b)) / 7
if (!isIntegral.call(yd, 0.0001)) return [0, 0, 0]
var y = yd.truncate
var x = mid - 2*a - y
return [x, y, y - x]
}
var sol = pascal.call(11, 4, 40, 151)
if (sol[0] != 0) {
Fmt.print("Solution is: x = $d, y = $d, z = $d", sol[0], sol[1], sol[2])
} else {
System.print("There is no solution")
}</lang>
{{out}}
<pre>
Solution is: x = 5, y = 13, z = 8
</pre>
=={{header|zkl}}==
|