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.
You need to give n sequential numbers the sum of which will equal to the cube of the given number. For example if n =4, you will have to find 4 odd numbers the sum of which will equal to 4^3. If n=6 you have to find 6 odd numbers the sum of which will equal to 6^3. Also, you have to follow the mathematical formula according to which a1, a2=a1+2, a3 = a2 +2 etc. Hope this helps
It is in the description, you need to take a closer look (Admittedly, it's easy to overlook that single character
n
).The description states:
findSummands(3) = [7,9,11] // because 7 + 9 + 11 = 27, the cube of 3. Note that there are only n = 3 elements in the array.
You're right ! Somehow I saw the first note but not the last one...
FYI, in JS
0 === 0n
isfalse
.As for hashing, not everything is hashable. Yes, the scope of the Kata only covers primitives, but generally relying on hashing is icky. This Kata is about equality. If == says they're equal, they are, period. Structural equality suffices, no need to check for nominal type equality.
Hi. I'm the one who made the Python translation. False and 0 are equal in Python. Nothing to do about that. It's like trying to differentiate between 0 and 0n in JS.
OK, so: thank you for the suggestion, but I'm not taking it. I'll post some closing thoughts on Discord.
Of course if you compare something other than the object itself, you can get false. You can also do
str(True) == str(1)
->False
.Yes. In fact using
is
doesn't work at all for almost any data types besides ints (sometimes), str (sometimes)None
and bools. For examplerange(3) is range(3)
->False
.You've convinced me, but have you convinced OP? ( Or is s/he just wrong? )
It doesn't need mentioning at all in python. We have none of the jsesque confusion over comparisons. bool inherits int, and False has the value 0.
python has no primitive values. that's not a concept.
So if I don't want to redefine "normal" language semantics, the Python version should just use
==
as equality, andFalse == 0
?But now you are redefining what it means to be "equal". In JS there are two types of equality, both
==
and===
. This is important because==
is a very loose form of equality. In Python==
is a much morereasonablestrict equality, and is thus the only type of equality used.is
is not an equality comparison but rather a check of whether the objects are the literally the same object in memory.For example consider this:
So, since this kata is about checking equality of elements, and in Python
0
andFalse
are equal (and same for1
andTrue
) then it makes sense foreq_all([1, True])
to beTrue
.Infinite iterables are a possibility in this kata.
Loading more items...