{- |
Description: Symmetric and completely balanced binary trees
Copyright: Copyright (C) 2021 Yoo Chung
License: GPL-3.0-or-later
Maintainer: dev@chungyc.org

Some solutions to "Problems.P58" of Ninety-Nine Haskell "Problems".
-}
module Solutions.P58 (symmetricBalancedTrees) where

import           Problems.BinaryTrees
import           Problems.P55
import           Problems.P56

-- | Construct all symmetric, completely balanced binary trees with a given number of nodes.
symmetricBalancedTrees :: Int -> [Tree ()]
symmetricBalancedTrees :: Int -> [Tree ()]
symmetricBalancedTrees = (Tree () -> Bool) -> [Tree ()] -> [Tree ()]
forall a. (a -> Bool) -> [a] -> [a]
filter Tree () -> Bool
forall a. Tree a -> Bool
symmetric ([Tree ()] -> [Tree ()]) -> (Int -> [Tree ()]) -> Int -> [Tree ()]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [Tree ()]
completelyBalancedTrees