]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/052/052.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / extra / project-euler / 052 / 052.factor
index 1b3b9ba1f11abb108413db3b5f5705d91f8d153a..037cc87288420e13ab0823aaaef63ba22287663d 100644 (file)
@@ -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
@@ -25,20 +24,20 @@ IN: project-euler.052
 <PRIVATE
 
 : map-nx ( n x -- seq )
-    [ 1+ * ] with map ; inline
+    [ 1 + * ] with map ; inline
 
 : all-same-digits? ( seq -- ? )
     [ 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? [
         2dup swap map-nx all-same-digits?
-        [ nip ] [ 1+ next-all-same ] if
+        [ nip ] [ 1 + next-all-same ] if
     ] [
-        1+ next-all-same
+        1 + next-all-same
     ] if ;
 
 PRIVATE>