Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matuu/find-parent-challenge
https://github.com/matuu/find-parent-challenge
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/matuu/find-parent-challenge
- Owner: matuu
- Created: 2024-08-03T15:42:18.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-03T15:46:43.000Z (5 months ago)
- Last Synced: 2024-08-03T16:57:32.909Z (5 months ago)
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Find parent challenge
Read [challenge.md](challenge.md)
Check [tests.py](tests%2Ftests.py) to see how it works.
Here an example (the same of the challenge give):
```python
"""
root ->
a ->
c
d
b
"""
from cli import FileNode, find_parentroot = FileNode("root")
node_a, node_b, node_c, node_d = tuple(FileNode(x) for x in "abcd")root.add_child(node_a)
root.add_child(node_b)
node_a.add_child(node_c)
node_a.add_child(node_d)assert find_parent(root, node_a, node_b) == root
assert find_parent(root, node_c, node_d) == node_a
```