From 2bdcba57319a12e5f5b2b619338b421420ab7776 Mon Sep 17 00:00:00 2001
From: Eric Mertens <emertens@galois.com>
Date: Tue, 15 Apr 2008 23:09:23 -0700
Subject: [PATCH] Add solution for project-euler.117

---
 extra/project-euler/117/117.factor | 42 ++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 extra/project-euler/117/117.factor

diff --git a/extra/project-euler/117/117.factor b/extra/project-euler/117/117.factor
new file mode 100644
index 0000000000..5056560a85
--- /dev/null
+++ b/extra/project-euler/117/117.factor
@@ -0,0 +1,42 @@
+! Copyright (c) 2008 Eric Mertens
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel math splitting sequences ;
+
+IN: project-euler.117
+
+! http://projecteuler.net/index.php?section=problems&id=117
+
+! DESCRIPTION
+! -----------
+
+! Using a combination of black square tiles and oblong tiles chosen
+! from: red tiles measuring two units, green tiles measuring three
+! 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?
+
+! SOLUTION
+! --------
+
+! This solution uses a simple dynamic programming approach using the
+! following recurence relation
+
+! ways(i) = 1 | i <= 0
+! ways(i) = ways(i-4) + ways(i-3) + ways(i-2) + ways(i-1)
+
+<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 ;
+
+: euler117 ( -- m )
+    50 (euler117) ;