Does Leap have typos in its description - or is there an algorithm that I don't know about? :)

This is about canonical-data.json in Leap in Problem Specs.

The descriptions below have two cases that refer to 3 and 125. Those numbers don’t appear in the description of the exercise. Why are they here?

I imagine there’s some algorithm that Erik taught me in the Leap video, but I don’t remember it. Should they be here or should we stick to the numbers used in the description?

    {
      "uuid": "9d70f938-537c-40a6-ba19-f50739ce8bac",
      "description": "year divisible by 100 but not by 3 is still not a leap year",
      "property": "leapYear",
      "input": {
        "year": 1900
      },
      "expected": false
    },
    {
      "uuid": "57902c77-6fe9-40de-8302-587b5c27121e",
      "description": "year divisible by 400 but not by 125 is still a leap year",
      "property": "leapYear",
      "input": {
        "year": 2400
      },
      "expected": true
    },

Added in 2019, leap: Add years that refute some unusual factors (#1581) · exercism/problem-specifications@f8aaffb · GitHub

I think the tests can remain.

Not a bug!

See: leap: Add years that refute some unusual factors by petertseng · Pull Request #1581 · exercism/problem-specifications · GitHub

leap 1.6.0

Some implementations unexpectedly pass the entire test suite:

  • Replacing 4 with 499, 998, or 1996
  • Replacing 100 with 5, 10, or 20
  • Replacing 100 with 3, 6, 12, 15, 30, 60, 75, 150, 300
  • Replacing 400 with 125, 250, 500, 1000, or 2000

Adding these test cases would correctly point out that these solutions
are incorrect.

I think it’s a bit unusual since no student is going to write such an
implementation except a student deliberately trying to slip past the
tests.
Or maybe a student trying to micro-optimise? Maybe they are trying to
test whether division by small numbers is faster than division by large
numbers?

But discussion participants have deemed that the cost of three tests is
worth the benefit of reducing mental overhead of mentors, since such
solutions have in fact been seen in the wild.

OK thanks both!

I’ve stripped the numbers out of the descriptions out of Bootcamp version as they’re student facing and confusing.

I’ll step away from Problem Specs though! :grin:

1 Like

Would it make sense to have some sort of “notes” associated with the less obvious tests?

2 Likes

As in the notes at the top of the file in some of the canonical datas? If so, yes. A link to what Glenn linked to is probably enough?