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.
Fixed tests are not future-proof: it will break after 2034.
Initial code has duplicate param
day
.no novelty in task, no random tests, author long gone
Not an issue?
It really depends on your logic. Not all ways of doing this add both divisors to the array. i.e. when getting factors of 72 and you are testing 2, not all algorithms will also add 36 in the same iteration. If you take a functional approach such as filtering a range of 2..x, x needs to be the initial input divided by 2. If you are looping and adding both divisors, then square root works fine.
This comment is hidden because it contains spoiler information about the solution
FYI - You can split using a regex rather than doing a replace + split.
Instructions and tests didn't specify, but I assumed we couldn't use the first word unchanged. What happens with this test:
@unclesnottie spoke - I think - about Elixir. In Elixir curly braces don't denote sets but tuples (tuples are ordered). There are many languages in this kata and few languages share the same notation for sets, arrays, tuples, pairs and so on. The aim of the kata is not to return a set but to return according to each language an array of arrays or of pairs or a list of pairs , of tuples or etc...
I hope the author don't confuse them:-) but it might be possible. Have a look at the description and you will see many notations. I understand that one can be a bit confused, you included:-)
Technically, yes. The use of curly brackets is misleading here (and in my opinion should be omitted, if anything, only the returned object should be possibly considered a set). The description asks for all tuples
(a, b)
, but obviously those tuples also imply(b, a)
.In other words, yes.
{15, 21}
is the same as{21, 15}
, but((15,21), (21,15))
and{(15, 21), (21, 15)}
are perfectly valid notations. It seems the description does not make a distinction between these brackets - which may lead to confusion.Under normal circumstances, curly brackets denote a set. In this case, the author appears to confuse the two.
Why wouldn't the return value for:
removNb(26) should return [ {15, 21}, {21, 15} ]
simply be[ {15, 21} ]
? Mathematically speaking the set of {15, 21} is the same as the set of {21, 15}.I think this Kata needs a test where
m == n
. Such astesting(37, 37, 37, [["M: 37", "B: 5", "C: 4"]])
. I only mention this because the top solution in Elixir is currently wrong for this test.I don't think you need the
def howmuch(n, n), do: []
part. I usedStream.filter_map
and the case form == n
works. It may look like an optimization, but actually it is wrong. Try adding a testtesting(37, 37, 37, [["M: 37", "B: 5", "C: 4"]])
. I think the author should add such a test.Draw a picture and add stuff up by hand. It's much easier then.