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

Cars-assemble: fix tests failing due to floating point precision #610

Merged
merged 2 commits into from
Mar 12, 2024

Conversation

tasxatzial
Copy link
Member

@tasxatzial tasxatzial commented Jan 22, 2024

A simple fix for the issue described below:

https://forum.exercism.org/t/cant-solve-cars-assemble-because-of-floating-point-precision/9242

The current tests check if two double numbers x, y are equal, and as a result some of them are failing when the numbers aren't identical. Two possible solutions:

  • Check if the two numbers are close enough using a check like abs(x-y)<epsilon.
  • Truncate doubles to floats. This lowers the required precision required for the tests to pass.

This PR employs the second approach.

Copy link
Contributor

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this Jan 22, 2024
@tasxatzial
Copy link
Member Author

I've just realized that my PR introduces a small typo . I'll correct it when it's reopened.


(deftest ^{:task 1} production-rate-speed-7-test
(deftest ^{:task 1} production-rate-speeed-7-test
Copy link
Member

Choose a reason for hiding this comment

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

Is this change intentional? The validate exercise step should fail here.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's the typo i'm talking about.

@tasxatzial
Copy link
Member Author

@bobbicodes Do you have some time to review this one?

@bobbicodes bobbicodes reopened this Mar 12, 2024
Copy link
Member

@bobbicodes bobbicodes left a comment

Choose a reason for hiding this comment

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

Yeah I suppose this would fix a lot of problems with this exercise, which is not supposed to be a challenge, it should be simple at this point. I'll wait to merge it until the typo is fixed.

@tasxatzial
Copy link
Member Author

It's ready. Thanks!

@bobbicodes bobbicodes merged commit e43ba25 into exercism:main Mar 12, 2024
2 checks passed
@tasxatzial tasxatzial deleted the cars-assemble-p1 branch March 12, 2024 23:34
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.

3 participants