Skip to content

Add the relative-distance exercise - #910

Merged
rabestro merged 1 commit into
mainfrom
add-relative-distance
Nov 9, 2026
Merged

rabestro merged 1 commit into
mainfrom
add-relative-distance

Conversation

@rabestro

@rabestro rabestro commented Nov 8, 2026

Copy link
Copy Markdown
Member

Adds Relative Distance, which the Java track already has.

The API follows the Java track: the family tree goes to the constructor and the query is a method.

class RelativeDistance(familyTree: Map[String, List[String]]):
  def degreeOfSeparation(personA: String, personB: String): Option[Int] = ???

"No known relationship" is None: the canonical data expects null, and the track already uses Option for "no answer" (e.g. binary-search). Java returns -1 instead.

Scala 3 syntax

The stub, the example and the test suite are written in the braceless style that .scalafmt.conf asks for (removeOptionalBraces, convertToNewSyntax). All three pass scalafmt --test with the track's config.

The suite is generated from the canonical data by bin/generate-tests. Its template doesn't use the shared header / test_open macros, because those still emit braces. It lays the suite out the way scalafmt would: wrapping at maxColumn (160), with trailing commas and the -> arrows aligned as align.preset = most does. When the shared macros move to the braceless style, this template can switch back to them.

Checked locally

  • bin/test relative-distance: 7/7 against the example
  • the stub compiles with the suite: the first test fails with NotImplementedError, the other six are pending
  • bin/generate-tests --check, configlet lint and configlet sync -e relative-distance are clean

🤖 Generated with Claude Code

Ported from the Java track. "No known relationship" is `None`: the
canonical data's `null` becomes an `Option[Int]`.

The suite is generated from the canonical data. Unlike the other
generated suites it is written in the Scala 3 braceless style that
.scalafmt.conf asks for, laid out the way scalafmt would lay it out, so
its template does not use the shared header/test_open macros, which
still emit braces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Hello 👋 Thanks for your PR.

This repo does not currently have dedicated maintainers. Our cross-track maintainers team will attempt to review and merge your PR, but it will likely take longer for your PR to be reviewed.

If you enjoy contributing to Exercism and have a track-record of doing so successfully, you might like to become an Exercism maintainer for this track.

Please feel free to ask any questions, or chat to us about anything to do with this PR or the reviewing process on the Exercism forum.

(cc @exercism/cross-track-maintainers)

@rabestro rabestro added the ready-to-translate The English in this PR is final; queue its translations label Nov 9, 2026
exercism-i18n Bot added a commit to exercism/i18n that referenced this pull request Nov 9, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@exercism-i18n

exercism-i18n Bot commented Nov 9, 2026

Copy link
Copy Markdown

This PR has been translated 🚀

@rabestro rabestro self-assigned this Nov 9, 2026
@rabestro
rabestro requested a review from a team November 9, 2026 11:28

@IsaacG IsaacG left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

Note, as a general rule, translation should only happen after approval, right before merging. That avoids multiple translations if a change is requested, reducing the cost.

@rabestro
rabestro merged commit a9908c5 into main Nov 9, 2026
11 of 12 checks passed
@rabestro
rabestro deleted the add-relative-distance branch November 9, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-translate The English in this PR is final; queue its translations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants