Paste: Euler 4
Author: | jdrake |
Mode: | factor |
Date: | Tue, 23 Dec 2008 09:13:12 |
Plain Text |
USING: kernel sequences fry math.ranges math.parser sorting arrays prettyprint ;
IN: euler4
: all-tuples ( seqs -- seqs ) dup length 1 = [ flip ] [ unclip-last-slice [ all-tuples ] dip [ '[ _ suffix ] map ] with map concat ] if ;
: all-threenumberproducts ( -- seq ) 100 999 [a,b] dup 2array all-tuples [ product ] map ;
: palindrome? ( string -- ? ) dup reverse = ;
: euler4 ( -- ) all-threenumberproducts
[ number>string ] map
[ palindrome? ] filter
[ string>number ] map
natural-sort
reverse
first . ;
New Annotation