Project Euler solution simplification

db4
Aaron Schaefer 2008-02-08 20:43:44 -05:00
parent d206ff9067
commit 751b013e2b
2 changed files with 3 additions and 3 deletions

View File

@ -32,7 +32,7 @@ IN: project-euler.045
DEFER: next-solution DEFER: next-solution
: (next-solution) ( n hexagonal -- n ) : (next-solution) ( n hexagonal -- hexagonal )
dup pentagonal? [ nip ] [ drop next-solution ] if ; dup pentagonal? [ nip ] [ drop next-solution ] if ;
: next-solution ( n -- m ) : next-solution ( n -- m )

View File

@ -1,6 +1,6 @@
! Copyright (c) 2008 Aaron Schaefer. ! Copyright (c) 2008 Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: combinators.lib kernel math math.combinatorics math.ranges sequences ; USING: combinators.lib kernel math math.combinatorics math.ranges ;
IN: project-euler.053 IN: project-euler.053
! http://projecteuler.net/index.php?section=problems&id=53 ! http://projecteuler.net/index.php?section=problems&id=53
@ -27,7 +27,7 @@ IN: project-euler.053
! -------- ! --------
: euler053 ( -- answer ) : euler053 ( -- answer )
23 100 [a,b] [ dup [ nCk ] with map [ 1000000 > ] count ] sigma ; 23 100 [a,b] [ dup [ nCk 1000000 > ] with count ] sigma ;
! [ euler053 ] 100 ave-time ! [ euler053 ] 100 ave-time
! 64 ms run / 2 ms GC ave time - 100 trials ! 64 ms run / 2 ms GC ave time - 100 trials