{- |
Description: Binary tree layout; constant distance at each level
Copyright: Copyright (C) 2021 Yoo Chung
License: GPL-3.0-or-later
Maintainer: dev@chungyc.org

Part of Ninety-Nine Haskell "Problems".  Some solutions are in "Solutions.P65".
-}
module Problems.P65 (layoutLevelConstant, tree65) where

import           Problems.BinaryTrees
import qualified Solutions.P65        as Solution

{- |
An alternative layout method is depicted in the illustration below:

![Layout example](images/BinaryTrees/Layout-P65.svg)

Find out the rules and write the corresponding function.
Use the same conventions as in "Problems.P64".

=== Examples

>>> layoutLevelConstant tree65
Branch ('n',(15,1)) (Branch ('k',(7,2)) (Branch ('c',(3,3)) ...

===  __Hint__

On a given level, the horizontal distance between neighboring nodes is constant.
-}
layoutLevelConstant :: Tree a -> Tree (a, (Int,Int))
layoutLevelConstant :: forall a. Tree a -> Tree (a, (Int, Int))
layoutLevelConstant = forall a. Tree a -> Tree (a, (Int, Int))
Solution.layoutLevelConstant

-- | Tree used as the example for "Problems.P65".
tree65 :: Tree Char
tree65 :: Tree Char
tree65 = forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'n'
         (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'k'
           (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'c'
             (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'a' forall a. Tree a
Empty forall a. Tree a
Empty)
             (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'e'
               (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'd' forall a. Tree a
Empty forall a. Tree a
Empty)
               (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'g' forall a. Tree a
Empty forall a. Tree a
Empty)))
           (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'm' forall a. Tree a
Empty forall a. Tree a
Empty))
         (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'u'
           (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'p'
             forall a. Tree a
Empty
             (forall a. a -> Tree a -> Tree a -> Tree a
Branch Char
'q' forall a. Tree a
Empty forall a. Tree a
Empty))
           forall a. Tree a
Empty)