Skip to content

feat: add relative-distance exercise - #309

Open
metif12 wants to merge 2 commits into
exercism:mainfrom
metif12:add/relative-distance
Open

metif12 wants to merge 2 commits into
exercism:mainfrom
metif12:add/relative-distance

Conversation

@metif12

@metif12 metif12 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

What

Adds the relative-distance practice exercise, the first of the new exercises split out of #307.

  • relative-distance.v — stub, with the signature and a description of what to return
  • .meta/example.v — example solution: a breadth-first search from one person to the other, treating siblings as one degree apart
  • run_test.v — 7 tests, built from the canonical data in problem-specifications
  • .meta/config.json, .meta/tests.toml, .docs/instructions.md, .docs/introduction.md
  • config.json — registers the exercise (difficulty 3)

This is one self-contained commit and touches nothing outside the exercise, so it can be merged on its own.

Verification

  • bin/verify-exercises-in-docker (the current vlang-test-runner image, V 0.4.8): pass, 7/7 tests.
  • V 0.5.2, the version vlang/setup-v installs for bin/test in CI: pass.
  • configlet lint passes; v fmt -l and v vet are clean on the new files.

For the merge commit

Not needed here: a brand new exercise does not change the outcome of any existing exercise's tests.

@keiravillekode

Copy link
Copy Markdown
Contributor

Please write a .meta/test_generator.py for relative-distance

metif12 and others added 2 commits October 4, 2026 16:15
Adds the relative-distance practice exercise, following the track
conventions: a snake_case stub in the exercise root, an example solution
in .meta, and a run_test.v suite built from the canonical data in
problem-specifications. Registers the exercise in config.json.

The example solution does a breadth-first search from one person to the
other, treating siblings as one degree apart.

Verified with bin/verify-exercises-in-docker (the current test runner
image) and with V 0.5.2 for bin/test. configlet lint passes, and
v fmt -l / v vet are clean on the new files.
Adds .meta/test_generator.py, so run_test.v is produced by
generators/generate.py from the canonical data rather than written by hand.

Two differences from the hand-written version, both a consequence of the
generator:

  - The family trees are inlined into each test instead of being two shared
    consts. generators/generate.py reads HEADER as a static string before it
    looks at any case, so there is no way to build the trees into it from the
    canonical data, and hard-coding them would defeat the point of the
    generator. Each test is now self-contained.
  - The last test is named after its canonical description, which is more
    verbose than the hand-written name.

The tree data itself is unchanged: the 52-entry tree used by two tests and the
51-entry tree used by the third compare equal, entry for entry, to the consts
they replace.

Verified:

  - the generate + v fmt cycle is stable: three runs produce the same bytes
  - v test passes on all 115 practice exercises with V 0.5.2 7647ce1
  - relative-distance passes in exercism/vlang-test-runner
  - configlet lint passes; ruff check and ruff format are clean
@metif12
metif12 force-pushed the add/relative-distance branch from 8938e34 to 5dd70c3 Compare October 4, 2026 12:55
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.

2 participants