Ad
  • Custom User Avatar

    0 is not technically positive. sould clarify language. Otherwise, nice kata!

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    Probably. Apparently there's not a test for that. Although, really, the kata doesn't specify what you should do if a number is 1. If the number has divisors, you print them. If the number is prime, you say it's prime. What do you do for 1? Empty string? Something else?

  • Default User Avatar

    Would that not flag 1 as prime?