urgas9 / tree-bracket-representation

:evergreen_tree: Reading and writing of a string tree bracket representation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tree-bracket-representation

Test & Lint all

Reading and writing of a string tree bracket representation in multiple programming languages.

What is this project about?

It is a simple hoby project, created mainly to learn new tools, languages and to be able to directly compare pros and cons of each language. So there will be many solutions in the repo, divided by programming languages, e.g. java and go.

The goal of the program is to read and write tree structure from a bracket string representation. Read more on the representation from this link but bare in mind that this library supports reading and writing of general trees as well.

For example, the below tree:

        A
    /   |   \
  CD    E    I
       / \
      F   G

could simply be presented as:

A(CD)(E(F)(G))(I)

on the other hand, here are some examples of invalid tree strings:

A(CD)a      // there is undefined node a
()          // two errors: the root node and its first child have no name
(A)         // the root node has no name

See more valid and invalid examples in the files used for tests across different implementations in ./examples folder.

Requirements

Each language should add support for the following function:

  • object constructor: parses a bracket tree string representation to an internal object structure and stores initial bracket tree string
  • find("A"): finds the first occurrence of node with name A and returns object presentation of the node
  • addChild("D(C(M))(L)"): adds child D to the tree node
  • countLeaves(): returns a number of nodes that have no children
  • toBracketRepresentation(): converts the internal object structure back to bracket tree string representation

For each language there should also be:

  • written tests that read invalid and valid test cases from JSON files stored in ./examples folder.
  • a linting tool to be added to check for code style.
  • the execution of tests and lint tool should be included in GitHub Actions workflow file.
  • written README.md file with status and example usage

How to use?

Check each for a README file in each language's folder.

About

:evergreen_tree: Reading and writing of a string tree bracket representation


Languages

Language:Java 23.9%Language:Go 22.1%Language:Kotlin 19.2%Language:Rust 18.3%Language:Python 15.2%Language:Makefile 1.3%