https://github.com/hyfi06/challenge-javascript-11s
challenge-javascript-11s - Zero and one parents problem
https://github.com/hyfi06/challenge-javascript-11s
challenge javascript platzi-master
Last synced: 3 months ago
JSON representation
challenge-javascript-11s - Zero and one parents problem
- Host: GitHub
- URL: https://github.com/hyfi06/challenge-javascript-11s
- Owner: hyfi06
- License: mit
- Created: 2020-04-06T00:22:37.000Z (about 5 years ago)
- Default Branch: develop
- Last Pushed: 2020-04-06T01:38:23.000Z (about 5 years ago)
- Last Synced: 2025-01-21T13:38:43.334Z (4 months ago)
- Topics: challenge, javascript, platzi-master
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# challenge-javascript-11 - Zero and one parents problem
Suppose we have some input data describing a graph of relationships between parents and children over multiple generations. The data is formatted as a list of (parent, child) pairs, where each individual is assigned a unique integer identifier.
### Example
In this diagram, 3 is a child of 1 and 2, and 5 is a child of 4:
```md
1 2 4
\ / / | \
3 5 8 9
\ / \ \
6 7 11
```Example input:
```js
parentChildPairs = [
[1, 3], [2, 3], [3, 6], [5, 6],
[5, 7], [4, 5], [4, 8], [4, 9], [9, 11]
]
```## Installation
```bash
npm install
```## Test
```bash
npm run test
```## Challenge
Write a function that takes this data as input and returns two collections: one containing all individuals with zero known parents, and one containing all individuals with exactly one known parent.
Example output:
```js
[
[1, 2, 4], // Individuals with zero parents
[5, 7, 8, 9, 11] // Individuals with exactly one parent
]
```## Submit challenge solution
You must "Fork" this project, solve the problem and create a Pull Request to this repository.
## Contribute
If someone wants to add or improve something, I invite them to collaborate directly in this repository: challenge-javascript-11
# License
challenge-javascript-11 is released under the MIT license.