diff --git a/extra/project-euler/039/039.factor b/extra/project-euler/039/039.factor index 1ad163d507..613e03a05c 100644 --- a/extra/project-euler/039/039.factor +++ b/extra/project-euler/039/039.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2008 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays kernel math math.ranges - namespaces project-euler.common sequences ; +USING: arrays kernel math math.ranges namespaces project-euler.common +sequences sequences.extras ; IN: project-euler.039 ! http://projecteuler.net/index.php?section=problems&id=39 @@ -56,7 +56,7 @@ PRIVATE> : euler039 ( -- answer ) [ - 1000 count-perimeters p-count get [ supremum ] keep index + 1000 count-perimeters p-count get arg-max ] with-scope ; ! [ euler039 ] 100 ave-time diff --git a/extra/project-euler/069/069.factor b/extra/project-euler/069/069.factor index 5094dcd674..1e7520f25c 100644 --- a/extra/project-euler/069/069.factor +++ b/extra/project-euler/069/069.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2009 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: combinators fry kernel math math.primes math.primes.factors math.ranges - project-euler.common sequences ; +USING: combinators fry kernel math math.primes math.primes.factors +math.ranges project-euler.common sequences sequences.extras ; IN: project-euler.069 ! http://projecteuler.net/index.php?section=problems&id=69 @@ -47,7 +47,7 @@ PRIVATE> : euler069 ( -- answer ) 2 1000000 [a,b] [ totient-ratio ] map - [ supremum ] keep index 2 + ; + arg-max 2 + ; ! [ euler069 ] 10 ave-time ! 25210 ms ave run time - 115.37 SD (10 trials) diff --git a/extra/project-euler/070/070.factor b/extra/project-euler/070/070.factor index 499ce21c34..09f1098655 100644 --- a/extra/project-euler/070/070.factor +++ b/extra/project-euler/070/070.factor @@ -1,8 +1,9 @@ ! Copyright (c) 2010 Aaron Schaefer. All rights reserved. ! The contents of this file are licensed under the Simplified BSD License ! A copy of the license is available at http://factorcode.org/license.txt -USING: arrays assocs combinators.short-circuit kernel math math.combinatorics - math.functions math.primes math.ranges project-euler.common sequences ; +USING: arrays combinators.short-circuit kernel math math.combinatorics +math.functions math.primes project-euler.common sequences +sequences.extras ; FROM: project-euler.common => permutations? ; IN: project-euler.070 @@ -54,7 +55,7 @@ IN: project-euler.070 first2 { [ drop 7 10^ < ] [ permutations? ] } 2&& ; : minimum-ratio ( seq -- n ) - [ [ first2 / ] map [ infimum ] keep index ] keep nth first ; + [ [ first2 / ] map arg-min ] keep nth first ; PRIVATE> diff --git a/extra/project-euler/099/099.factor b/extra/project-euler/099/099.factor index 64c5533a69..36fae686d5 100644 --- a/extra/project-euler/099/099.factor +++ b/extra/project-euler/099/099.factor @@ -1,7 +1,8 @@ ! Copyright (c) 2008 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: io.encodings.ascii io.files kernel math math.functions math.parser - math.vectors sequences splitting project-euler.common ; +USING: io.encodings.ascii io.files kernel math math.functions +math.parser math.vectors project-euler.common sequences +sequences.extras splitting ; IN: project-euler.099 ! http://projecteuler.net/index.php?section=problems&id=99 @@ -39,7 +40,7 @@ IN: project-euler.099 flip first2 swap [ log ] map v* ; : solve ( seq -- index ) - simplify [ supremum ] keep index 1 + ; + simplify arg-max 1 + ; PRIVATE>