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

Darts - is there an inconsistency between the tests and the overview page description? #839

Closed
armhzjz opened this issue Jan 8, 2023 · 6 comments

Comments

@armhzjz
Copy link

armhzjz commented Jan 8, 2023

According to the overview page of the Darts problem, the radius of the concentric circles are defined as:

The outer circle has a radius of 10 units (this is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1. Of course, they are all centered at the same point (that is, the circles are concentric defined by the coordinates (0, 0).

However, the test "test_just_outside_the_middle_circle" is defined as:

{
   coordinate_t landing_position = { -3.6F, -3.6F };
   uint8_t expected = 1;
   uint8_t actual = score(landing_position);
   TEST_ASSERT_EQUAL_UINT8(expected, actual);
}

This is confusing because, (also according to the overview page of the Darts problem) the expected number of points for positions under the radius of 5.0 (i.e. middle circle) should be 5 (not 1). This causes the tests to failed (or pushes the user to implement something that passes the test - ignoring the specification of the problem).

I see more discrepancies between some other tests and the specification of the problem.
Am I missing something?
I see the overview page was recently updated (Dec. 2022). Were the tests not updated as well?

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2023

Hello. Thanks for opening an issue on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed.

That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use [this link](https://forum.exercism.org/new-topic?title=Darts%20-%20is%20there%20an%20inconsistency%20between%20the%20tests%20and%20the%20overview%20page%20description?&body=According%20to%20the%20%5Boverview%20page%20of%20the%20Darts%20problem%5D(https://exercism.org/tracks/c/exercises/darts),%20the%20radius%20of%20the%20concentric%20circles%20are%20defined%20as:%0D%0A%0D%0A%3E%20The%20outer%20circle%20has%20a%20radius%20of%2010%20units%20(this%20is%20equivalent%20to%20the%20total%20radius%20for%20the%20entire%20target),%20the%20middle%20circle%20a%20radius%20of%205%20units,%20and%20the%20inner%20circle%20a%20radius%20of%201.%20Of%20course,%20they%20are%20all%20centered%20at%20the%20same%20point%20(that%20is,%20the%20circles%20are%20%5Bconcentric%5D(http://mathworld.wolfram.com/ConcentricCircles.html)%20defined%20by%20the%20coordinates%20(0,%200).%0D%0A%0D%0AHowever,%20the%20test%20%22test_just_outside_the_middle_circle%22%20is%20defined%20as:%0D%0A%0D%0A%60%60%60%60%60%60static%20void%20test_just_outside_the_middle_circle(void)%0D%0A%7B%0D%0A%20%20%20coordinate_t%20landing_position%20=%20%7B%20-3.6F,%20-3.6F%20%7D;%0D%0A%20%20%20uint8_t%20expected%20=%201;%0D%0A%20%20%20uint8_t%20actual%20=%20score(landing_position);%0D%0A%20%20%20TEST_ASSERT_EQUAL_UINT8(expected,%20actual);%0D%0A%7D%0D%0A%60%60%60%60%60%60%0D%0AThis%20is%20confusing%20because,%20(also%20according%20to%20the%20%5Boverview%20page%20of%20the%20Darts%20problem%5D(https://exercism.org/tracks/c/exercises/darts))%20the%20expected%20number%20of%20points%20for%20positions%20under%20the%20radius%20of%205.0%20(i.e.%20middle%20circle)%20should%20be%205%20(not%201).%20This%20causes%20the%20tests%20to%20failed%20(or%20pushes%20the%20user%20to%20implement%20something%20that%20passes%20the%20test%20-%20ignoring%20the%20specification%20of%20the%20problem).%0D%0A%0D%0AI%20see%20more%20discrepancies%20between%20some%20other%20tests%20and%20the%20specification%20of%20the%20problem.%0D%0AAm%20I%20missing%20something?%0D%0AI%20see%20the%20overview%20page%20was%20recently%20updated%20(Dec.%202022).%20Were%20the%20tests%20not%20updated%20as%20well?&category=c) to copy this into a new topic there.


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

@github-actions github-actions bot closed this as completed Jan 8, 2023
@armhzjz
Copy link
Author

armhzjz commented Jan 8, 2023

The very first test is inconsistent with the second test.
The first test is defined as:

static void test_missed_target(void)
{
   coordinate_t landing_position = { -9.0F, 9.0F };
   uint8_t expected = 0;
   uint8_t actual = score(landing_position);
   TEST_ASSERT_EQUAL_UINT8(expected, actual);
}

while the second test is defined as:

Some basic Git commands are:

static void test_on_the_outer_circle(void)
{
      // delete this line to run test
   coordinate_t landing_position = { 0.0F, 10.0F };
   uint8_t expected = 1;
   uint8_t actual = score(landing_position);
   TEST_ASSERT_EQUAL_UINT8(expected, actual);
}

Shouldn't the expected values be 1 and 1 respectively?

@ryanplusplus
Copy link
Member

According to the overview page of the Darts problem, the radius of the concentric circles are defined as:

The outer circle has a radius of 10 units (this is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1. Of course, they are all centered at the same point (that is, the circles are concentric defined by the coordinates (0, 0).

However, the test "test_just_outside_the_middle_circle" is defined as:

{
   coordinate_t landing_position = { -3.6F, -3.6F };
   uint8_t expected = 1;
   uint8_t actual = score(landing_position);
   TEST_ASSERT_EQUAL_UINT8(expected, actual);
}

This is confusing because, (also according to the overview page of the Darts problem) the expected number of points for positions under the radius of 5.0 (i.e. middle circle) should be 5 (not 1). This causes the tests to failed (or pushes the user to implement something that passes the test - ignoring the specification of the problem).

The distance from origin to { -3.6F, -3.6F } is ~5.09 so this is outside of the middle circle and inside of the outer circle. This is consistent with the description in the overview:

If the dart lands in the outer circle of the target, player earns 1 point.
If the dart lands in the middle circle of the target, player earns 5 points.

Since the distance from origin is greater than 5, it earns only 1 point.

I see more discrepancies between some other tests and the specification of the problem. Am I missing something? I see the overview page was recently updated (Dec. 2022). Were the tests not updated as well?

The problem specifications and implementations are machine-generated and not always updated in lockstep, but the changes are usually just additions, removals, or tweaks of tests, not wholesale re-definitions of the problem.

@ryanplusplus
Copy link
Member

The very first test is inconsistent with the second test. The first test is defined as:

static void test_missed_target(void)
{
   coordinate_t landing_position = { -9.0F, 9.0F };
   uint8_t expected = 0;
   uint8_t actual = score(landing_position);
   TEST_ASSERT_EQUAL_UINT8(expected, actual);
}

while the second test is defined as:

Some basic Git commands are:

static void test_on_the_outer_circle(void)
{
      // delete this line to run test
   coordinate_t landing_position = { 0.0F, 10.0F };
   uint8_t expected = 1;
   uint8_t actual = score(landing_position);
   TEST_ASSERT_EQUAL_UINT8(expected, actual);
}

Shouldn't the expected values be 1 and 1 respectively?

For the first test, the distance from origin is ~12.73 and this is greater than 10 so 0 points are earned. I suspect that you are not correctly calculating the distance from origin. Check out the Wikipedia article on Euclidean distance.

@armhzjz
Copy link
Author

armhzjz commented Jan 8, 2023

So, what I missed, is that the function should then calculate the hypotenuse based on the Cartesian coordinates?

@armhzjz
Copy link
Author

armhzjz commented Jan 8, 2023

For the first test, the distance from origin is ~12.73 and this is greater than 10 so 0 points are earned. I suspect that you are not correctly calculating the distance from origin. Check out the Wikipedia article on Euclidean distance.

Right. Thank you very much again.

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

No branches or pull requests

2 participants