-! Copyright (c) 2008 Eric Mertens
+! Copyright (c) 2008 Eric Mertens.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.order splitting sequences ;
-
+USING: kernel math project-euler.common sequences ;
IN: project-euler.117
! http://projecteuler.net/index.php?section=problems&id=117
! units, and blue tiles measuring four units, it is possible to tile a
! row measuring five units in length in exactly fifteen different ways.
-! How many ways can a row measuring fifty units in length be tiled?
+! How many ways can a row measuring fifty units in length be tiled?
+
! SOLUTION
! --------
<PRIVATE
-: short ( seq n -- seq n )
- over length min ;
-
: next ( seq -- )
[ 4 short tail* sum ] keep push ;
-PRIVATE>
-
: (euler117) ( n -- m )
- V{ 1 } clone tuck [ next ] curry times peek ;
+ [ V{ 1 } clone ] dip over [ next ] curry times last ;
-: euler117 ( -- m )
+PRIVATE>
+
+: euler117 ( -- answer )
50 (euler117) ;
+
+! [ euler117 ] 100 ave-time
+! 0 ms ave run time - 0.29 SD (100 trials)
+
+SOLUTION: euler117