From 89852b22d4b1f304008801750973a810eb2f1fb8 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Tue, 16 Dec 2008 22:43:22 -0500 Subject: [PATCH 01/11] Add Project Euler solution for problem 1 from IRC --- extra/project-euler/001/001-tests.factor | 1 + extra/project-euler/001/001.factor | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/extra/project-euler/001/001-tests.factor b/extra/project-euler/001/001-tests.factor index 8d2461a510..1cab275619 100644 --- a/extra/project-euler/001/001-tests.factor +++ b/extra/project-euler/001/001-tests.factor @@ -4,3 +4,4 @@ IN: project-euler.001.tests [ 233168 ] [ euler001 ] unit-test [ 233168 ] [ euler001a ] unit-test [ 233168 ] [ euler001b ] unit-test +[ 233168 ] [ euler001c ] unit-test diff --git a/extra/project-euler/001/001.factor b/extra/project-euler/001/001.factor index 1e49be9a60..c9145c9b73 100644 --- a/extra/project-euler/001/001.factor +++ b/extra/project-euler/001/001.factor @@ -1,4 +1,4 @@ -! Copyright (c) 2007 Aaron Schaefer. +! Copyright (c) 2007, 2008 Aaron Schaefer, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.ranges sequences ; IN: project-euler.001 @@ -51,4 +51,11 @@ PRIVATE> ! [ euler001b ] 100 ave-time ! 0 ms run / 0 ms GC ave time - 100 trials + +: euler001c ( -- answer ) + 1000 [ { 3 5 } [ mod 0 = ] with contains? ] filter sum ; + +! [ euler001c ] 100 ave-time +! 0 ms ave run time - 0.06 SD (100 trials) + MAIN: euler001 From adac92dfa5ad7439fc8a0c23078afcb4975e2a6b Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Sat, 20 Dec 2008 18:53:17 -0500 Subject: [PATCH 02/11] Remove roll from Project Euler problem 33 solution --- extra/project-euler/033/033.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/project-euler/033/033.factor b/extra/project-euler/033/033.factor index d0c79c220a..2cc114a545 100644 --- a/extra/project-euler/033/033.factor +++ b/extra/project-euler/033/033.factor @@ -33,7 +33,7 @@ IN: project-euler.033 10 99 [a,b] dup cartesian-product [ first2 < ] filter ; : safe? ( ax xb -- ? ) - [ 10 /mod ] bi@ -roll = rot zero? not and nip ; + [ 10 /mod ] bi@ [ = ] dip zero? not and nip ; : ax/xb ( ax xb -- z/f ) 2dup safe? [ [ 10 /mod ] bi@ 2nip / ] [ 2drop f ] if ; From 51530700f406f2effe8ff1f6cde953a10d7a0665 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Wed, 7 Jan 2009 18:47:32 -0500 Subject: [PATCH 03/11] Add number-length word and clean cartesian-product --- extra/project-euler/common/common.factor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor index 1a57a91e5e..49eb730632 100644 --- a/extra/project-euler/common/common.factor +++ b/extra/project-euler/common/common.factor @@ -56,7 +56,7 @@ PRIVATE> >lower [ CHAR: a - 1+ ] sigma ; : cartesian-product ( seq1 seq2 -- seq1xseq2 ) - swap [ swap [ 2array ] with map ] with map concat ; + [ [ 2array ] with map ] curry map concat ; : log10 ( m -- n ) log 10 log / ; @@ -74,6 +74,9 @@ PRIVATE> : number>digits ( n -- seq ) [ dup 0 = not ] [ 10 /mod ] [ ] produce reverse nip ; +: number-length ( n -- m ) + log10 floor 1+ >integer ; + : nth-triangle ( n -- n ) dup 1+ * 2 / ; From 9d44708e1d87e795f30d63b37e3f7b5908b4c160 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Wed, 1 Apr 2009 18:43:45 -0400 Subject: [PATCH 04/11] Fix contains? -> any? rename issue --- extra/project-euler/001/001.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/project-euler/001/001.factor b/extra/project-euler/001/001.factor index 17f8d0386d..68e1ff032a 100644 --- a/extra/project-euler/001/001.factor +++ b/extra/project-euler/001/001.factor @@ -53,7 +53,7 @@ PRIVATE> : euler001c ( -- answer ) - 1000 [ { 3 5 } [ mod 0 = ] with contains? ] filter sum ; + 1000 [ { 3 5 } [ mod 0 = ] with any? ] filter sum ; ! [ euler001c ] 100 ave-time ! 0 ms ave run time - 0.06 SD (100 trials) From c698a83a12f87713fea953ae4aec54c980bfde17 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Wed, 1 Apr 2009 19:29:19 -0400 Subject: [PATCH 05/11] Add divisor? math function --- basis/math/functions/functions-docs.factor | 8 +++++++- basis/math/functions/functions-tests.factor | 16 +++++++++++----- basis/math/functions/functions.factor | 5 ++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/basis/math/functions/functions-docs.factor b/basis/math/functions/functions-docs.factor index 33a5d96fc4..02fcd5f4d9 100644 --- a/basis/math/functions/functions-docs.factor +++ b/basis/math/functions/functions-docs.factor @@ -13,7 +13,8 @@ ARTICLE: "integer-functions" "Integer functions" "Tests:" { $subsection power-of-2? } { $subsection even? } -{ $subsection odd? } ; +{ $subsection odd? } +{ $subsection divisor? } ; ARTICLE: "arithmetic-functions" "Arithmetic functions" "Computing additive and multiplicative inverses:" @@ -269,6 +270,11 @@ HELP: gcd { $description "Computes the positive greatest common divisor " { $snippet "d" } " of " { $snippet "x" } " and " { $snippet "y" } ", and another value " { $snippet "a" } " satisfying:" { $code "a*y = d mod x" } } { $notes "If " { $snippet "d" } " is 1, then " { $snippet "a" } " is the inverse of " { $snippet "y" } " modulo " { $snippet "x" } "." } ; +HELP: divisor? +{ $values { "x" integer } { "y" integer } { "?" "a boolean" } } +{ $description "Tests if " { $snippet "y" } " is a divisor of " { $snippet "x" } ". This is the same thing as saying " { $snippet "x" } " is divisible by " { $snippet "y" } "." } +{ $notes "Returns t for both negative and positive divisors, as well as trivial and non-trivial divisors." } ; + HELP: mod-inv { $values { "x" integer } { "n" integer } { "y" integer } } { $description "Outputs an integer " { $snippet "y" } " such that " { $snippet "xy = 1 (mod n)" } "." } diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 9f5ce36be1..4c9d151fd8 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -32,13 +32,13 @@ IN: math.functions.tests [ 1.0 ] [ 0 cosh ] unit-test [ 0.0 ] [ 1 acosh ] unit-test - + [ 1.0 ] [ 0 cos ] unit-test [ 0.0 ] [ 1 acos ] unit-test - + [ 0.0 ] [ 0 sinh ] unit-test [ 0.0 ] [ 0 asinh ] unit-test - + [ 0.0 ] [ 0 sin ] unit-test [ 0.0 ] [ 0 asin ] unit-test @@ -97,11 +97,17 @@ IN: math.functions.tests : verify-gcd ( a b -- ? ) 2dup gcd - [ rot * swap rem ] dip = ; + [ rot * swap rem ] dip = ; [ t ] [ 123 124 verify-gcd ] unit-test [ t ] [ 50 120 verify-gcd ] unit-test +[ t ] [ 0 42 divisor? ] unit-test +[ t ] [ 42 7 divisor? ] unit-test +[ t ] [ 42 -7 divisor? ] unit-test +[ t ] [ 42 42 divisor? ] unit-test +[ f ] [ 42 16 divisor? ] unit-test + [ 3 ] [ 5 7 mod-inv ] unit-test [ 78572682077 ] [ 234829342 342389423843 mod-inv ] unit-test @@ -150,4 +156,4 @@ IN: math.functions.tests 1067811677921310779 2135623355842621559 [ >bignum ] tri@ ^mod -] unit-test \ No newline at end of file +] unit-test diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index a87b3995d7..799bb04169 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -111,6 +111,9 @@ PRIVATE> : lcm ( a b -- c ) [ * ] 2keep gcd nip /i ; foldable +: divisor? ( x y -- ? ) + mod 0 = ; + : mod-inv ( x n -- y ) [ nip ] [ gcd 1 = ] 2bi [ dup 0 < [ + ] [ nip ] if ] @@ -198,7 +201,7 @@ M: real sin fsin ; GENERIC: sinh ( x -- y ) foldable -M: complex sinh +M: complex sinh >float-rect [ [ fsinh ] [ fcos ] bi* * ] [ [ fcosh ] [ fsin ] bi* * ] 2bi rect> ; From ca9fb1fcf1e68a1536bc0280f8a6f55281a84197 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Wed, 1 Apr 2009 21:53:18 -0400 Subject: [PATCH 06/11] Update usages of divisor? where appropriate --- basis/calendar/calendar.factor | 8 ++++---- basis/math/functions/functions-docs.factor | 6 +++--- basis/math/primes/factors/factors.factor | 4 ++-- extra/project-euler/001/001.factor | 4 ++-- extra/project-euler/004/004.factor | 6 +++--- extra/project-euler/014/014.factor | 6 +++--- extra/project-euler/043/043.factor | 6 +++--- extra/project-euler/052/052.factor | 7 +++---- extra/project-euler/common/common.factor | 5 ++--- 9 files changed, 25 insertions(+), 27 deletions(-) diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 104941ddb2..54741567bb 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays kernel math math.functions namespaces sequences -strings system vocabs.loader threads accessors combinators -locals classes.tuple math.order summary combinators.short-circuit ; +USING: accessors arrays classes.tuple combinators combinators.short-circuit + kernel locals math math.functions math.order namespaces sequences strings + summary system threads vocabs.loader ; IN: calendar HOOK: gmt-offset os ( -- hours minutes seconds ) @@ -136,7 +136,7 @@ CONSTANT: day-abbreviations3 GENERIC: leap-year? ( obj -- ? ) M: integer leap-year? ( year -- ? ) - dup 100 mod zero? 400 4 ? mod zero? ; + dup 100 divisor? 400 4 ? divisor? ; M: timestamp leap-year? ( timestamp -- ? ) year>> leap-year? ; diff --git a/basis/math/functions/functions-docs.factor b/basis/math/functions/functions-docs.factor index 02fcd5f4d9..f7d0d5a941 100644 --- a/basis/math/functions/functions-docs.factor +++ b/basis/math/functions/functions-docs.factor @@ -271,9 +271,9 @@ HELP: gcd { $notes "If " { $snippet "d" } " is 1, then " { $snippet "a" } " is the inverse of " { $snippet "y" } " modulo " { $snippet "x" } "." } ; HELP: divisor? -{ $values { "x" integer } { "y" integer } { "?" "a boolean" } } -{ $description "Tests if " { $snippet "y" } " is a divisor of " { $snippet "x" } ". This is the same thing as saying " { $snippet "x" } " is divisible by " { $snippet "y" } "." } -{ $notes "Returns t for both negative and positive divisors, as well as trivial and non-trivial divisors." } ; +{ $values { "m" integer } { "n" integer } { "?" "a boolean" } } +{ $description "Tests if " { $snippet "n" } " is a divisor of " { $snippet "m" } ". This is the same thing as asking if " { $snippet "m" } " is divisible by " { $snippet "n" } "." } +{ $notes "Returns t for both negative and positive divisors, as well as for trivial and non-trivial divisors." } ; HELP: mod-inv { $values { "x" integer } { "n" integer } { "y" integer } } diff --git a/basis/math/primes/factors/factors.factor b/basis/math/primes/factors/factors.factor index 199b72b7e1..9acc2b58c6 100644 --- a/basis/math/primes/factors/factors.factor +++ b/basis/math/primes/factors/factors.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007-2009 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays combinators kernel make math math.primes sequences ; +USING: arrays combinators kernel make math math.fucntions math.primes sequences ; IN: math.primes.factors : euler001c ( -- answer ) - 1000 [ { 3 5 } [ mod 0 = ] with any? ] filter sum ; + 1000 [ { 3 5 } [ divisor? ] with any? ] filter sum ; ! [ euler001c ] 100 ave-time ! 0 ms ave run time - 0.06 SD (100 trials) diff --git a/extra/project-euler/004/004.factor b/extra/project-euler/004/004.factor index ff62b4e181..fe09914d9f 100644 --- a/extra/project-euler/004/004.factor +++ b/extra/project-euler/004/004.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2007 Aaron Schaefer, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: hashtables kernel math math.ranges project-euler.common sequences - sorting sets ; +USING: hashtables kernel math math.functions math.ranges project-euler.common + sequences sorting sets ; IN: project-euler.004 ! http://projecteuler.net/index.php?section=problems&id=4 @@ -21,7 +21,7 @@ IN: project-euler.004 diff --git a/extra/project-euler/043/043.factor b/extra/project-euler/043/043.factor index 7edcd14364..75241499e1 100644 --- a/extra/project-euler/043/043.factor +++ b/extra/project-euler/043/043.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2008 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: combinators.short-circuit kernel math math.combinatorics math.parser - math.ranges project-euler.common sequences sets sorting ; +USING: combinators.short-circuit kernel math math.functions math.combinatorics + math.parser math.ranges project-euler.common sequences sets sorting ; IN: project-euler.043 ! http://projecteuler.net/index.php?section=problems&id=43 @@ -36,7 +36,7 @@ IN: project-euler.043 integer swap mod zero? ; + [ 1- dup 3 + ] dip subseq 10 digits>integer swap divisor? ; : interesting? ( seq -- ? ) { diff --git a/extra/project-euler/052/052.factor b/extra/project-euler/052/052.factor index 1b3b9ba1f1..c25b1adcc0 100644 --- a/extra/project-euler/052/052.factor +++ b/extra/project-euler/052/052.factor @@ -1,8 +1,7 @@ ! Copyright (c) 2008 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: combinators.short-circuit kernel math - project-euler.common sequences sorting - grouping ; +USING: combinators.short-circuit kernel math math.functions + project-euler.common sequences sorting grouping ; IN: project-euler.052 ! http://projecteuler.net/index.php?section=problems&id=52 @@ -31,7 +30,7 @@ IN: project-euler.052 [ number>digits natural-sort ] map all-equal? ; : candidate? ( n -- ? ) - { [ odd? ] [ 3 mod 0 = ] } 1&& ; + { [ odd? ] [ 3 divisor? ] } 1&& ; : next-all-same ( x n -- n ) dup candidate? [ diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor index 0ad3225e3e..ba8c81fbf4 100644 --- a/extra/project-euler/common/common.factor +++ b/extra/project-euler/common/common.factor @@ -44,7 +44,7 @@ IN: project-euler.common : (sum-divisors) ( n -- sum ) dup sqrt >integer [1,b] [ - [ 2dup mod 0 = [ 2dup / + , ] [ drop ] if ] each + [ 2dup divisor? [ 2dup / + , ] [ drop ] if ] each dup perfect-square? [ sqrt >fixnum neg , ] [ drop ] if ] { } make sum ; @@ -120,7 +120,7 @@ PRIVATE> factor-2s dup [ 1+ ] [ perfect-square? -1 0 ? ] [ dup sqrt >fixnum [1,b] ] tri* [ - dupd mod 0 = [ [ 2 + ] dip ] when + dupd divisor? [ [ 2 + ] dip ] when ] each drop * ; ! These transforms are for generating primitive Pythagorean triples @@ -137,4 +137,3 @@ SYNTAX: SOLUTION: [ drop in get vocab (>>main) ] [ [ . ] swap prefix (( -- )) define-declared ] 2bi ; - From ed9a63311cf1a9acf8d23f182650ac3efec760ba Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Wed, 1 Apr 2009 22:03:45 -0400 Subject: [PATCH 07/11] Fix typo and update a combinator usage in calendar --- basis/calendar/calendar.factor | 2 +- basis/math/primes/factors/factors.factor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 54741567bb..7a03fe4408 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -348,7 +348,7 @@ M: duration time- #! good for any date since October 15, 1582 [ dup 2 <= [ [ 1- ] [ 12 + ] bi* ] when - [ dup [ 4 /i + ] keep [ 100 /i - ] keep 400 /i + ] dip + [ dup [ 4 /i + ] [ 100 /i - ] [ 400 /i + ] tri ] dip [ 1+ 3 * 5 /i + ] keep 2 * + ] dip 1+ + 7 mod ; diff --git a/basis/math/primes/factors/factors.factor b/basis/math/primes/factors/factors.factor index 9acc2b58c6..278bf70b3d 100644 --- a/basis/math/primes/factors/factors.factor +++ b/basis/math/primes/factors/factors.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007-2009 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays combinators kernel make math math.fucntions math.primes sequences ; +USING: arrays combinators kernel make math math.functions math.primes sequences ; IN: math.primes.factors Date: Thu, 2 Apr 2009 11:58:35 -0400 Subject: [PATCH 08/11] Solution to Project Euler problem 49 --- extra/project-euler/049/049-tests.factor | 4 ++ extra/project-euler/049/049.factor | 74 ++++++++++++++++++++++++ extra/project-euler/project-euler.factor | 16 ++--- 3 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 extra/project-euler/049/049-tests.factor create mode 100644 extra/project-euler/049/049.factor diff --git a/extra/project-euler/049/049-tests.factor b/extra/project-euler/049/049-tests.factor new file mode 100644 index 0000000000..679647ac18 --- /dev/null +++ b/extra/project-euler/049/049-tests.factor @@ -0,0 +1,4 @@ +USING: project-euler.049 tools.test ; +IN: project-euler.049.tests + +[ 296962999629 ] [ euler049 ] unit-test diff --git a/extra/project-euler/049/049.factor b/extra/project-euler/049/049.factor new file mode 100644 index 0000000000..2fa51fa221 --- /dev/null +++ b/extra/project-euler/049/049.factor @@ -0,0 +1,74 @@ +! Copyright (c) 2009 Aaron Schaefer. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays byte-arrays fry hints kernel math math.combinatorics + math.functions math.parser math.primes project-euler.common sequences sets ; +IN: project-euler.049 + +! http://projecteuler.net/index.php?section=problems&id=49 + +! DESCRIPTION +! ----------- + +! The arithmetic sequence, 1487, 4817, 8147, in which each of the terms +! increases by 3330, is unusual in two ways: (i) each of the three terms are +! prime, and, (ii) each of the 4-digit numbers are permutations of one another. + +! There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes, +! exhibiting this property, but there is one other 4-digit increasing sequence. + +! What 12-digit number do you form by concatenating the three terms in this +! sequence? + + +! SOLUTION +! -------- + + [ + '[ 10 /mod _ [ 1+ ] change-nth dup 0 > ] loop drop + ] keep ; + +HINTS: count-digits fixnum ; + +: permutations? ( n m -- ? ) + [ count-digits ] bi@ = ; + +: collect-permutations ( seq -- seq ) + [ V{ } clone ] [ dup ] bi* [ + dupd '[ _ permutations? ] filter + [ diff ] keep pick push + ] each drop ; + +: potential-sequences ( -- seq ) + 1000 9999 primes-between + collect-permutations [ length 3 > ] filter ; + +: arithmetic-terms ( m n -- seq ) + 2dup [ swap - ] keep + 3array ; + +: (find-unusual-terms) ( n seq -- seq/f ) + [ [ arithmetic-terms ] with map ] keep + '[ _ [ peek ] dip member? ] find nip ; + +: find-unusual-terms ( seq -- seq/? ) + unclip-slice over (find-unusual-terms) [ + nip + ] [ + dup length 3 >= [ find-unusual-terms ] [ drop f ] if + ] if* ; + +: 4digit-concat ( seq -- str ) + 0 [ [ 10000 * ] dip + ] reduce ; + +PRIVATE> + +: euler049 ( -- answer ) + potential-sequences [ find-unusual-terms ] map sift + [ { 1487 4817 8147 } = not ] find nip 4digit-concat ; + +! [ euler049 ] 100 ave-time +! 206 ms ave run time - 10.25 SD (100 trials) + +SOLUTION: euler049 diff --git a/extra/project-euler/project-euler.factor b/extra/project-euler/project-euler.factor index 3d10dbcfbd..1e1da38a3f 100644 --- a/extra/project-euler/project-euler.factor +++ b/extra/project-euler/project-euler.factor @@ -14,14 +14,14 @@ USING: definitions io io.files io.pathnames kernel math math.parser project-euler.037 project-euler.038 project-euler.039 project-euler.040 project-euler.041 project-euler.042 project-euler.043 project-euler.044 project-euler.045 project-euler.046 project-euler.047 project-euler.048 - project-euler.052 project-euler.053 project-euler.055 project-euler.056 - project-euler.057 project-euler.059 project-euler.067 project-euler.071 - project-euler.073 project-euler.075 project-euler.076 project-euler.079 - project-euler.092 project-euler.097 project-euler.099 project-euler.100 - project-euler.116 project-euler.117 project-euler.134 project-euler.148 - project-euler.150 project-euler.151 project-euler.164 project-euler.169 - project-euler.173 project-euler.175 project-euler.186 project-euler.190 - project-euler.203 project-euler.215 ; + project-euler.049 project-euler.052 project-euler.053 project-euler.055 + project-euler.056 project-euler.057 project-euler.059 project-euler.067 + project-euler.071 project-euler.073 project-euler.075 project-euler.076 + project-euler.079 project-euler.092 project-euler.097 project-euler.099 + project-euler.100 project-euler.116 project-euler.117 project-euler.134 + project-euler.148 project-euler.150 project-euler.151 project-euler.164 + project-euler.169 project-euler.173 project-euler.175 project-euler.186 + project-euler.190 project-euler.203 project-euler.215 ; IN: project-euler Date: Thu, 2 Apr 2009 12:10:51 -0400 Subject: [PATCH 09/11] Minor typo in solution for PE problem 49 --- extra/project-euler/049/049.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/project-euler/049/049.factor b/extra/project-euler/049/049.factor index 2fa51fa221..15dd7ed6d2 100644 --- a/extra/project-euler/049/049.factor +++ b/extra/project-euler/049/049.factor @@ -43,7 +43,7 @@ HINTS: count-digits fixnum ; : potential-sequences ( -- seq ) 1000 9999 primes-between - collect-permutations [ length 3 > ] filter ; + collect-permutations [ length 3 >= ] filter ; : arithmetic-terms ( m n -- seq ) 2dup [ swap - ] keep + 3array ; From e0a8def090a8ec4bfd0f51c02072f0e910c2165c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 2 Apr 2009 13:48:53 -0500 Subject: [PATCH 10/11] Fix generate-help to not open thousands of windows in UI --- basis/help/html/html.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/help/html/html.factor b/basis/help/html/html.factor index 66d864b2a0..d880af5b55 100644 --- a/basis/help/html/html.factor +++ b/basis/help/html/html.factor @@ -60,7 +60,7 @@ M: topic url-of topic>filename ; : help>html ( topic -- xml ) [ article-title ] [ drop help-stylesheet ] - [ [ help ] with-html-writer ] + [ [ print-topic ] with-html-writer ] tri simple-page ; : generate-help-file ( topic -- ) From 7e0f271cf3f4eb428aa40a85369b54b338585572 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 2 Apr 2009 17:00:29 -0500 Subject: [PATCH 11/11] fix typo in docs --- basis/math/functions/functions.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 799bb04169..1eac321e3b 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -111,7 +111,7 @@ PRIVATE> : lcm ( a b -- c ) [ * ] 2keep gcd nip /i ; foldable -: divisor? ( x y -- ? ) +: divisor? ( m n -- ? ) mod 0 = ; : mod-inv ( x n -- y )