RosettaCodeData/Task/Pascals-triangle-Puzzle/Factor/pascals-triangle-puzzle.factor
2023-07-01 13:44:08 -04:00

13 lines
409 B
Factor

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