Ad
  • 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.

  • Custom User Avatar

    Do you have suggestions for what I should do to resolve the issues you have raised? I'm not sure exactly what you want changed.

    Approximate equality or expecting the nearest representable value to the mathematical result or expecting the least representable value with which the amount reaches the target.

  • Custom User Avatar

    My intention in using phrases like the "exact value" and "maximum accuracy" wasn't meant to imply that we were getting the infinite value, just the value up to the default precision

    To get the result up to the default precision, intermediate values need to be more precise.

    I didn't want to get into the complexities of precision

    In this case approximate comparisons are the only option.

    test.assert_equals(required_interest_rate(Decimal('1000'), Decimal('1210'), 2, 2), Decimal('9.761769634030309398290702800')). Are you saying that the expected value in that test case is wrong?

    Yes, you can try applying Decimal('9.761769634030309398290702736') to 1000 and it will be closer to 1200.

    I'm not sure how that can be, since all the people who have solved the kata got exactly that value.

    Maybe they rounded in the same places to the same precision as the reference solution.

    It doesn't have round-off error - that's what the kata is trying to illustrate.

    In computing, a roundoff error, also called rounding error,is the difference between the result produced by a given algorithm using exact arithmetic and the result produced by the same algorithm using finite-precision, rounded arithmetic.

    (Wikipedia.) How can an irrational value not have an error when represented as a fraction?

  • Custom User Avatar

    The function should return the exact value

    This is impossible with a square root involved.

    which is Decimal('9.761769634030309398290702800')

    so, obviously, it's not exact.

    Do not round the result

    we want maximum accuracy in the result

    It's impossible because the result is infinite.

    One can set a desired precision for decimals, but to keep things simple this kata uses the default precision.

    Well, that's what I'm saying. It contradicts the previous sentences.
    Also, the result is 9.761769634030309398290702735987519695..., so with the default precision it's Decimal('9.761769634030309398290702736'). The value in the description isn't rounded correctly.

    Floating point should never be used in financial programming, because of round-off error. The function should return a decimal representing the interest rate as a percentage.

    Decimal is a floating point decimal number. It can't magically make infinite fractions finite, so it has the same issues as float.

  • Custom User Avatar

    Python isn't the only one, there are C++, Crystal, D, Factor, Groovy, Haskell, Java with libraries, Prolog, Raku, Rust with libraries, maybe something else (R?).
    Also, permutations can be replaced with product, the difference is less than 10 times here, so performance allows.

  • Custom User Avatar

    Other than that, every other issue has been solved.

    There are "четыре *тысячная" and "девять *тысячная" remaining in the description.

  • Custom User Avatar
  • Custom User Avatar

    "Odin" declines by gender: masculine - "odin", feminine - "odna", neuter (not in the kata) - "odno". The default form is masculine, while the word "tysyacha" (thousand) and the implicit word for 'part' (either whole as in 1.2 or fractional as in 2.1) are feminine.

  • Custom User Avatar
    • *двесте -> двести;
    • *девятсот (in some examples) -> девятьсот;
    • тысяч - thousand, expected to be nominative singular in the list starting with "1000 ->" -> тысяча;
    • *десяти тысячных - ten-thousandths, genitive plural -> десятитысячных;
    • "1.234 ... одна целая *двесте тридцать четыре *тысячная", same with 991.999 -> одна целая двести тридцать четыре тысячных.
  • Custom User Avatar

    Looks fixed.

  • Custom User Avatar
  • Custom User Avatar

    This doesn't look like a new idea. Validating various numbers like ISBN with simple math has been done before.

    https://www.codewars.com/kata/51fc12de24a9d8cb0e000001

  • Loading more items...