6 kyu

Sherlock on pockets

290hagi
Description
Loading description...
Algorithms
Arrays
  • Please sign in or sign up to leave a comment.
  • AlgernonTheMouse Avatar

    pretty bad description, you say if pockets == nil i.e. if the first argument is nil, but what you really mean is if all the values in the hash are nil or empty arrays, or if the hash itself is empty.

  • dfhwze Avatar

    I had to click Train to figure out the real task here. The best description of this problem is hidden away in some comment in the code setup:

    # return array of suspects with illegal items in their pockets
    
  • Blind4Basics Avatar
    • missing sample tests
    • the design of the pockets doesn't make sense: single items should be stored in a single element array
    • daniloxxv Avatar
      • Added sample tests
      • Fixed the code and description to change ints to single element arrays
      Issue marked resolved by daniloxxv 6 years ago
    • Blind4Basics Avatar

      what do you think about removing pockets being nil and replace them with an empty array instead? That would make way more sense, imo.

    • daniloxxv Avatar

      Agreed. I thought of doing that, but it would invalidate pretty much all of the existing solutions. Would that be ok?

    • Blind4Basics Avatar

      no, that won't change anything since currently that's the user who's converting the nils to an empty array (I mean... If the user coded it in a clever way... 'XD ). But yeah, that's what beta phase is made for, so go ahead. That way, I won't have second thoughts when approving it to 7 kyus. ;)

      EDIT: mmh damn... already approved... :( Then, keep it that way instead.

    • daniloxxv Avatar

      Eh, sorry, I wasn't getting notifications on this post for some reason and approved it before seeing your first comment. I published it with the power user average ranking (6kyu), since the overall average seemed a bit too high (5kyu). Are you sure it's too late to change the nil/empty array thing, though? The author's solution would have to be updated, but aside from that it's a minor change.

    • Blind4Basics Avatar
      • change the rank: nope, unless an admin goes by
      • average was surprisingly high, even for pus... (old kata). Anyway...
      • update: don't bother. Keeping the nil stuff will at least enforce something.
  • Voile Avatar

    Also need random tests.

  • Voile Avatar

    It's not mentioned how a value of nil should be handled.

  • posgarou Avatar

    Good concept, but the description is very difficult to read and understand, as it is not in very idiomatic English. I had to read it a number of times to get the gist of the task.

    • cliffstamp Avatar

      Noting something is hard to understand isn't a resolvable issue as there is no way for anyone to know what you found hard to understand.

      Issue marked resolved by cliffstamp 6 years ago
  • moonfly Avatar

    The 2nd test case provided in the description is incorrect

  • hksong Avatar

    What is the difference between nil and [] for pockets?

    • hagi Avatar

      I think this doesn't matter for kata, but few comments ago I had idea that empty array can be for empty pockets, and nil can be for 'no pockets' in real life example ;)

      Issue marked resolved by hagi 11 years ago
  • mlabrum Avatar

    The description says values in pockets will be one or more things represented by numbers, but some test cases have nil values. If you want to have empty pockets in your test cases, either leave the person (and her/his pockets) out or make it an empty array and change the description to say that values will be zero or more numbers.

    I think the most straight-forward way to set up pockets is to have the key be a name (as it is) and the value be an array of pocket contents (numbers). An empty array will then mean an empty pocket.

    I also think the return value should be an array of suspects. Notably, this means returning an empty array instead of nil when there are no suspects.