From 625d4037feea41d05f3157a277c82db800de5651 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 17 Apr 2008 12:22:04 -0500 Subject: [PATCH] Minor tweak to project-euler --- extra/project-euler/150/150.factor | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/extra/project-euler/150/150.factor b/extra/project-euler/150/150.factor index 5b22a1b9f6..5d83f5a732 100644 --- a/extra/project-euler/150/150.factor +++ b/extra/project-euler/150/150.factor @@ -1,15 +1,21 @@ ! Copyright (c) 2008 Eric Mertens ! See http://factorcode.org/license.txt for BSD license. -USING: kernel math sequences locals ; +USING: kernel math sequences sequences.private locals hints ; IN: project-euler.150 +PRIVATE> USING: arrays kernel.private ; :: (euler150) ( m -- n ) [let | table [ sums-triangle ] | m [| x | x 1+ [| y | m x - [| z | - x z + table nth - [ y z + 1+ swap nth ] - [ y swap nth ] bi - - ] map partial-sums infimum + x z + table nth-unsafe + [ y z + 1+ swap nth-unsafe ] + [ y swap nth-unsafe ] bi - + ] map partial-sum-infimum ] map-infimum ] map-infimum ] ; +HINTS: (euler150) fixnum ; + : euler150 ( -- n ) 1000 (euler150) ;