]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/085/085.factor
factor: trim using lists
[factor.git] / extra / project-euler / 085 / 085.factor
index 6c70f65bf7ad7ecf810dfbb1de1e613f9afb73f1..3c04724c57184978cd95b864234f7af63cdd9bff 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2009 Guillaume Nargeot.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel math math.ranges project-euler.common
-sequences locals ;
+USING: accessors kernel math ranges project-euler.common
+sequences ;
 IN: project-euler.085
 
 ! http://projecteuler.net/index.php?section=problems&id=85
@@ -19,7 +19,7 @@ IN: project-euler.085
 ! SOLUTION
 ! --------
 
-! A grid measuring x by y contains x * (x + 1) * y * (x + 1) rectangles.
+! A grid measuring x by y contains x * (x + 1) * y * (x + 1) / 4 rectangles.
 
 <PRIVATE
 
@@ -29,9 +29,9 @@ IN: project-euler.085
 : rectangles-count ( a b -- n )
     2dup [ 1 + ] bi@ * * * 4 /i ; inline
 
-:: each-unique-product ( a b quot: ( i j -- ) -- )
-    a b [a,b] [| i |
-        i b [a,b] [| j |
+:: each-unique-product ( ... a b quot: ( ... i j -- ... ) -- ... )
+    a b [a..b] [| i |
+        i b [a..b] [| j |
             i j quot call
         ] each
     ] each ; inline
@@ -56,6 +56,6 @@ PRIVATE>
     area-of-nearest ;
 
 ! [ euler085 ] 100 ave-time
-! 2285 ms ave run time - 4.8 SD (100 trials)
+! 791 ms ave run time - 17.15 SD (100 trials)
 
 SOLUTION: euler085