summaryrefslogtreecommitdiff
path: root/H59.hs
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2015-04-06 13:53:37 +0800
committerJoe Zhao <ztuowen@gmail.com>2015-04-06 13:53:37 +0800
commit84e6753005e57827c78b50ad0a26ffa0d0da55e4 (patch)
treefabb8c6fb7f79ff1e39aca433ae15d481acd9485 /H59.hs
parent897055910d8bda98b3454b6f66ad697edc4676b3 (diff)
downloadh99-84e6753005e57827c78b50ad0a26ffa0d0da55e4.tar.gz
h99-84e6753005e57827c78b50ad0a26ffa0d0da55e4.tar.bz2
h99-84e6753005e57827c78b50ad0a26ffa0d0da55e4.zip
+59 +60
Diffstat (limited to 'H59.hs')
-rw-r--r--H59.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/H59.hs b/H59.hs
new file mode 100644
index 0000000..3d44ac3
--- /dev/null
+++ b/H59.hs
@@ -0,0 +1,13 @@
+module H59 where
+
+import Tree
+
+hbalTree :: Int -> [Tree Char]
+hbalTree 0 = [Empty]
+hbalTree h = [Branch 'x' x y | let tl = concatMap hbalTree $ filter (>=0) [h-2,h-1],x <- tl, y <- tl]
+
+hbalTree' 1 = [Branch 'x' Empty Empty]
+hbalTree' h = hbalhelper (h-1) [Branch 'x' Empty Empty] [Empty]
+ where
+ hbalhelper 0 x _ = x
+ hbalhelper n x y = hbalhelper (n-1) [Branch 'x' l r| let tl = x ++ y, l <- tl, r <- tl] x