a
    ¥Q•hõ  ã                   @   s    d Z ddlmZmZ dd„ ZdS )z%Generic tools for working with trees.é    )ÚceilÚlogc                    s  | sg S ˆ dksJ ‚t tt| ƒˆ ƒƒ}|dkr6t| ƒS g }d}ˆ |d  }tdt| ƒ|ƒD ]`}| ||| … ‰tˆƒ|k r‚ˆ} q¼tˆƒˆ kr°‡ ‡fdd„tdtˆƒˆ ƒD ƒ‰q‚| ˆ¡ qZ|�rt|ˆ ƒ‰tˆƒˆ t|ƒ krì| ˆ¡ n
| ˆ¡ t|ƒˆ k�sJ ‚|S )z�Build N-ary tree from sequence of leaf nodes.

    Return a list of lists where each non-leaf node is a list containing
    max n nodes.
    é   Nr   c                    s   g | ]}ˆ||ˆ  … ‘qS © r   )Ú.0Úk©ÚnÚsubtreer   úQ/var/www/sistema_ama/venv/lib/python3.9/site-packages/fontTools/misc/treeTools.pyÚ
<listcomp>    ó    z$build_n_ary_tree.<locals>.<listcomp>)r   r   ÚlenÚlistÚrangeÚappendÚbuild_n_ary_treeÚextend)Úleavesr	   ÚdepthÚrootZ
unassignedZ	full_stepÚir   r   r   r      s0    "

r   N)Ú__doc__Úmathr   r   r   r   r   r   r   Ú<module>   s   