How to resolve the algorithm Pascal's triangle/Puzzle step by step in the Factor programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pascal's triangle/Puzzle step by step in the Factor programming language
Table of Contents
Problem Statement
This puzzle involves a Pascals Triangle, also known as a Pyramid of Numbers. Each brick of the pyramid is the sum of the two bricks situated below it. Of the three missing numbers at the base of the pyramid, the middle one is the sum of the other two (that is, Y = X + Z).
Write a program to find a solution to this puzzle.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Pascal's triangle/Puzzle step by step in the Factor programming language
Source code in the factor programming language
USING: arrays backtrack combinators.extras fry grouping.extras
interpolate io kernel math math.ranges sequences ;
: 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
You may also check:How to resolve the algorithm Prime conspiracy step by step in the Elixir programming language
You may also check:How to resolve the algorithm Barnsley fern step by step in the Unicon programming language
You may also check:How to resolve the algorithm Next highest int from digits step by step in the Nim programming language
You may also check:How to resolve the algorithm Langton's ant step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Numeric error propagation step by step in the Raku programming language