Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This looks familiar, might be a duplicate, but I can't find it now.
6
is the length, the meaning of5
would be less clear. With the length, it's like indexing a full array from the end with.at(-ir)
.There's no year 0 in the Gregorian calendar.
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.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.
To get the result up to the default precision, intermediate values need to be more precise.
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.Maybe they rounded in the same places to the same precision as the reference solution.
(Wikipedia.) How can an irrational value not have an error when represented as a fraction?
This is impossible with a square root involved.
so, obviously, it's not exact.
It's impossible because the result is infinite.
Well, that's what I'm saying. It contradicts the previous sentences.
Also, the result is
9.761769634030309398290702735987519695...
, so with the default precision it'sDecimal('9.761769634030309398290702736')
. The value in the description isn't rounded correctly.Decimal
is a floating point decimal number. It can't magically make infinite fractions finite, so it has the same issues asfloat
.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.
There are "четыре *тысячная" and "девять *тысячная" remaining in the description.
It's always "девятьсот", no exceptions.
https://gramota.ru/poisk?query=девятьсот&mode=slovari
https://gramota.ru/poisk?query=девятсот&mode=slovari - not found
"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.
Looks fixed.
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...