Repository navigation
Conversation
Adds the baffling-birthdays practice exercise (difficulty 6), split out of exercism#307. The example estimates the probability of a shared birthday with a Monte Carlo simulation, as the canonical data asks for an estimate rather than an exact count. `month_and_day_of` in the example now loops `for day > 0` instead of `for {`, and returns `(0, 0)` after the loop. V 0.4.8 -- the version the current test runner image pins -- does not treat a bare `for {}` as an exhaustive loop and reports a missing return instead. The loop still always returns from inside for every day of a non-leap year, so the behaviour is unchanged and neither V version warns about the extra return. The tests average 25 runs against a 1.5 percentage-point tolerance, so this is the one exercise in the track with a probabilistic assertion. If that is not wanted in CI, this is the exercise to drop. Registers the exercise in config.json. 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the Baffling Birthdays practice exercise (difficulty 6), split out of #307.
baffling-birthdays.v-- stub.meta/example.v-- example solutionrun_test.v-- 17 tests, built from the canonical data inproblem-specifications.meta/config.json,.meta/tests.toml,.docs/config.json-- registers the exerciseAdjustments for the test runner's V version
month_and_day_ofin the example loopsfor day > 0instead offor {, andreturns
(0, 0)after the loop. V 0.4.8 does not treat a barefor {}as anexhaustive loop and reports a missing return instead. The loop still always
returns from inside for every day of a non-leap year, so the behaviour is
unchanged and neither V version warns about the extra return.
This exercise asserts a probability: the tests average 25 runs against a
1.5 percentage-point tolerance. If a probabilistic test is not wanted on the
track, this is the one to leave out.
One self-contained commit that touches nothing outside the exercise, so it can be merged on its own.
Verification
bin/verify-exercises-in-docker(the currentvlang-test-runnerimage, V 0.4.8): pass, 17/17 tests.vlang/setup-vinstalls forbin/testin CI: pass.configlet lintpasses;v fmt -landv vetare clean on the new files.For the merge commit
Not needed: a brand new exercise does not change the outcome of any existing exercise's tests.