Use tri instead of repeated keeps for PE solutions
parent
5aca313896
commit
96853249a4
|
@ -1,7 +1,7 @@
|
|||
! Copyright (c) 2008 Aaron Schaefer.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays combinators.lib kernel math math.ranges namespaces
|
||||
project-euler.common sequences ;
|
||||
USING: arrays combinators.cleave combinators.lib kernel math math.ranges
|
||||
namespaces project-euler.common sequences ;
|
||||
IN: project-euler.039
|
||||
|
||||
! http://projecteuler.net/index.php?section=problems&id=39
|
||||
|
@ -43,7 +43,7 @@ SYMBOL: p-count
|
|||
: (count-perimeters) ( seq -- )
|
||||
dup sum max-p < [
|
||||
dup sum adjust-p-count
|
||||
[ u-transform ] keep [ a-transform ] keep d-transform
|
||||
[ u-transform ] [ a-transform ] [ d-transform ] tri
|
||||
[ (count-perimeters) ] 3apply
|
||||
] [
|
||||
drop
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (c) 2008 Aaron Schaefer.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays combinators.lib kernel math math.ranges namespaces
|
||||
project-euler.common sequences ;
|
||||
USING: arrays combinators.cleave combinators.lib kernel math math.ranges
|
||||
namespaces project-euler.common sequences ;
|
||||
IN: project-euler.075
|
||||
|
||||
! http://projecteuler.net/index.php?section=problems&id=75
|
||||
|
@ -56,7 +56,7 @@ SYMBOL: p-count
|
|||
: (count-perimeters) ( seq -- )
|
||||
dup sum max-p < [
|
||||
dup sum adjust-p-count
|
||||
[ u-transform ] keep [ a-transform ] keep d-transform
|
||||
[ u-transform ] [ a-transform ] [ d-transform ] tri
|
||||
[ (count-perimeters) ] 3apply
|
||||
] [
|
||||
drop
|
||||
|
|
Loading…
Reference in New Issue