Ad
  • Custom User Avatar

    Most of the names are different, so just for consistency, although either way looks OK.

  • Custom User Avatar

    I folded in the wrong direction earlier, should have done this for early exiting. (I can't just quickly imagine the evaluation order without doing it step by step on paper, but, whatever the reason is, this version is faster. Maybe it's just the usual stricter evaluation thing.)

  • Custom User Avatar

    Another thing is too much laziness, all those lists and maybes there, see the other fork.

  • Custom User Avatar

    One thing is there's no early exit here (check the fork).
    Input distribution to optimize for isn't specified, so it's unclear if densness is good or bad. It's not slower for the "biased random tests", in which density is always about 100%.

  • Custom User Avatar

    Result<T, ()> is isomorphic to Option<T>, does it have any advantages?

  • Custom User Avatar

    I'm not sure if n % divisor != 0 is possible without more complicated stuff with high-precision fractions, but I have a version of the solution that seems to work for all other input.

  • Custom User Avatar

    And the reference solution is wrong for many other cases: (9, 9) -> expected 60, (15, 15) -> expected 2192. I sumbitted this version to see what should be done to generalize it and wasn't really expecting it to pass all the tests.

  • Custom User Avatar

    This assumes one particular implementation, while the rest of the description is just a math problem. Oversimplified, it's like "check if the number is even or odd, but you'll be given only numbers divisible by 3 to make sure the output is correct". It may be a valid constraint, but it's not the way to describe it.

  • Custom User Avatar

    In order to make the outputs exact

    A number of sets is always an integer, which is exact, so I think this statement should be reworded.

  • Custom User Avatar

    (2, 2) isn't tested, but it's still valid input according to the description.

  • Custom User Avatar
  • Custom User Avatar

    This looks familiar, might be a duplicate, but I can't find it now.

  • Custom User Avatar

    6 is the length, the meaning of 5 would be less clear. With the length, it's like indexing a full array from the end with .at(-ir).

  • Custom User Avatar
        it("should handle year 0", function() {
          const event = {title: 'Year Zero', year: '0 AD'};
    

    There's no year 0 in the Gregorian calendar.

  • Custom User Avatar

    But decimal should be preferred to floating point

    Decimal is a type, "decimal" is a base, "floating point" is... representation? or whatever it's called. "Decimal" is orthogonal to "floating point". Decimal is a floating point decimal number.

  • Loading more items...