Skip to content

fix: relative-distance corrections #2541

Closed
@vaeng

Description

@vaeng
          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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions