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.
0 is not technically positive. sould clarify language. Otherwise, nice kata!
After a couple of years on Codewars, this is still my favorite Kata. Shows a problem that is relevant in robotics but abstracted enough to not deal with the tedious stuff. My Algorithms and Data Structures class ought to be able to handle this, now, at the end of the course, I will see how they do tomorrow.
This comment is hidden because it contains spoiler information about the solution
It looks like groupBy is implying an order, and it is insisting of "order of first appearance in data set". That makes it hard (impossible?) to implement groupBy with sorting, and I have to say I feel a little cheated.When no orderBy is specified, it ought to be up to the query processor to deliver the data in the most convenient order.
GroupBy test#4 (multiple group-bys) reveals this:
Expected:
'[['teacher',
[['Peter',
[{ name: 'Peter',\n profession: 'teacher',\n age: 20,\n maritalStatus: 'married' },
{ name: 'Peter',\n profession: 'teacher',\n age: 20,\n maritalStatus: 'married' }]],
['Michael',
[{ name: 'Michael',\n profession: 'teacher',\n age: 50,\n maritalStatus: 'single' }]]]],
['scientific',
[['Anna',
[{ name: 'Anna',\n profession: 'scientific',\n age: 20,\n maritalStatus: 'married' },
{ name: 'Anna',\n profession: 'scientific',\n age: 20,\n maritalStatus: 'single' }]],
['Rose',
[{ name: 'Rose',\n profession: 'scientific',\n age: 50,\n maritalStatus: 'married' }]]]],
['politician',
[['Anna',
[{ name: 'Anna',\n profession: 'politician',\n age: 50,\n maritalStatus: 'married' }]]]]]',
My (rejected) result:
'[['teacher',
[['Peter',
[{ name: 'Peter',\n profession: 'teacher',\n age: 20,\n maritalStatus: 'married' },
{ name: 'Peter',\n profession: 'teacher',\n age: 20,\n maritalStatus: 'married' }]],
['Michael',
[{ name: 'Michael',\n profession: 'teacher',\n age: 50,\n maritalStatus: 'single' }]]]],
['scientific',
[['Rose',
[{ name: 'Rose',\n profession: 'scientific',\n age: 50,\n maritalStatus: 'married' }]],
['Anna',
[{ name: 'Anna',\n profession: 'scientific',\n age: 20,\n maritalStatus: 'married' },
{ name: 'Anna',\n profession: 'scientific',\n age: 20,\n maritalStatus: 'single' }]]]],
['politician',
[['Anna',
[{ name: 'Anna',\n profession: 'politician',\n age: 50,\n maritalStatus: 'married' }]]]]]'
Note that I accidentally sort Z-A, but that is not the issue.
Would that not flag 1 as prime?