The random tests are terrible. There's no point in generating 500k Member instances, and the whole output should be checked, not just a small hardcoded substring of it.
No sample tests.
Thanks you two! It was a good chance to try something different in the meanwhile :)
Until this kata is updated to use a newer version of Node, it won't work. In some other katas Node 12 is enabled and you could use it.
Hey Hanna! .flat() doesn't work in codewars :(
This comment is hidden because it contains spoiler information about the solution
O(N^2) is bad
The description should explain that you are expected to throw a NullReferenceException if the array is null.
But was: <System.ArgumentNullException: Value cannot be null.
Thank you (GrahamD) for raising this issue and thank you (JetFly) for providing these example test cases.
I've added them to the kata, with the addition of a couple that require the user to return "1 year".
It seems odd that the distance driven between the last fill up of the month and the first fillup of the next month is not included.
For example if you only fill up on the 1st of three consecutive months and drive 100 miles between filling up by this measurement you will have driven 0 miles each month when in fact you drove 100 miles each month.
tldr: U can't say that table is ordered, or the result is ordered(unless it's specified to order it).
You can always order finite set, as ordering require relation, and it is always possible to make relation between all objects in finite set.
Set of possible relations between elements of finite amount of sets is a carthesian product of those finite amount of sets,
relation is element of this set. In this case, we can simply tell that any result is ordered by relation x1x2...xn-1xn, where x~y means x is in relation with y.
More, ordering in sql makes preassumption that we want order result by '>' relation, or '<' in case of descending.
However, if we don't specify ordering, result of query should be treated as SET, same as tables in database, which means result is always UNORDERED (Disordered? It sounds like it has mental problems :D) unless we specify to order it somehow.
You're right. I'll give it some thought and write some. :)
The line (record) terminator is a carriage-return/line-feed combination. If the list is empty, there are no records (i.e. no lines), so there are no CrLfs to terminate them.
Think about a hypothetical process which is going to take your output as input and interpret it. The first thing it's (probably) going to do is check if the input is empty. If so, it will know there are no records. If not (and if it contains a CrLf, that counts as "not empty"), it's going to try and extract records from it.
Makes perfect sense to me, and I work with stuff like this all the time: each record must be terminated by a carriage-return/line-feed combination (in fact I often work with requirements where the record terminator is a | or something, meaning it's actually one continuous line in the file, but I digress). If there are no records, there are no record terminators.
Maybe I should just update the description to make it clearer. :)
Needs random tests