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

feat: add pathfinding exercise #2537

Merged
merged 12 commits into from
Mar 3, 2025
Merged

feat: add pathfinding exercise #2537

merged 12 commits into from
Mar 3, 2025

Conversation

vaeng
Copy link
Contributor

@vaeng vaeng commented Mar 2, 2025

This is an idea I proposed on Discord as a reaction to @ErikSchierboom's call for exercises.

@vaeng vaeng requested a review from a team as a code owner March 2, 2025 20:35
@BNAndras
Copy link
Member

BNAndras commented Mar 2, 2025

Degrees of separation make me think of https://en.m.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon. Maybe we could add a Kevin as a homage?

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely!

@vaeng vaeng merged commit bf0fa07 into main Mar 3, 2025
7 checks passed
@vaeng vaeng deleted the pathfinding-exercise branch March 3, 2025 13:18
@jiegillet
Copy link
Contributor

jiegillet 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.

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

Successfully merging this pull request may close these issues.

8 participants