project-euler.074: cleanup

db4
Slava Pestov 2009-09-22 05:19:26 -05:00
parent d84cfd1284
commit 81462d1479
1 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,7 @@
! Copyright (c) 2009 Guillaume Nargeot. ! Copyright (c) 2009 Guillaume Nargeot.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: assocs hashtables kernel math math.ranges USING: assocs hashtables kernel math math.ranges
project-euler.common sequences ; project-euler.common sequences sets ;
IN: project-euler.074 IN: project-euler.074
! http://projecteuler.net/index.php?section=problems&id=074 ! http://projecteuler.net/index.php?section=problems&id=074
@ -51,9 +51,10 @@ IN: project-euler.074
number>digits [ digit-factorial ] sigma ; number>digits [ digit-factorial ] sigma ;
: chain-length ( n -- n ) : chain-length ( n -- n )
61 <hashtable> [ 2dup at* nip f = ] [ 61 <hashtable>
2dup dupd set-at [ digits-factorial-sum ] dip [ 2dup key? not ]
] while nip assoc-size ; [ [ conjoin ] [ [ digits-factorial-sum ] dip ] 2bi ]
while nip assoc-size ;
PRIVATE> PRIVATE>