Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: relative-distance corrections #2541

Open
vaeng opened this issue Mar 7, 2025 · 3 comments
Open

fix: relative-distance corrections #2541

vaeng opened this issue Mar 7, 2025 · 3 comments

Comments

@vaeng
Copy link
Contributor

vaeng commented Mar 7, 2025

          I've been trying to implement this one in Elixir, but I'm having trouble solving it, I think some cases may have issues.
  1. "Direct parent-child relation" => degree 1, no problem
  2. "Sibling relationship" => expected degree between siblings is 1, but from the description I expected it to be 2, with the path being: left child => parent => right child. Bypassing the parent for siblings is fine as a rule, but it should be explicit.
  3. "Two degrees of separation, grandchild" => degree 2, no problem
  4. "Unrelated individuals" => no problem
  5. "Complex graph, cousins" => degree 4, but my solution gave degree 9. I did it by hand and I also get 9 (with the rule of siblings having a degree of separation 1, otherwise you would get 10)
  6. "Complex graph, no shortcut, far removed nephew" => degree 15, but my solution fives me 14 (it could be 15 without the siblings rule potentially, I did not do this one by hand)
  7. "Complex graph, some shortcuts, cross-down and cross-up, cousins three times removed" => degree 8, but my solution gives me no connection, and I confirmed by hand. Sofia doesn't have a parent, and she starts a second family with Qi in it.

@vaeng could you help me here?

Also in general, I like having large inputs, but only at the end when all base case have been covered. The cousin case, for example could be much smaller, it took me a long time to verify by hand.
I also noticed that the Elixir exercise generator does not preserve the ordering of the family tree entries, but with random order I never would have been able to check my solutions by hand, so maybe it's worth adding a comment saying that preserving the order would be a good idea.

Here is my tentative implementation.

Originally posted by @jiegillet in #2537 (comment)

@vaeng vaeng changed the title I've been trying to implement this one in Elixir, but I'm having trouble solving it, I think some cases may have issues. fix: relative-distance corrections Mar 7, 2025
@vaeng
Copy link
Contributor Author

vaeng commented Mar 7, 2025

Thank you for posting @jiegillet. I moved this to a new issue.

I was implementing this for C++ and had similar thoughts. I have to admit that I did not solve my solution programmatically and analyzed a mermaid graph I made by hand.

We should fix the tests (with new uuids etc).

@ErikSchierboom
Copy link
Member

Don't use new uuids. It is very unlikely that maintainers have already implemented the exercise and it'll just be messy. Ping me to force merge the fix PR

@ErikSchierboom
Copy link
Member

Any update on this @vaeng ? Would be a cool exercise to add to several tracks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants