Draft

Feed The Dogs

15 of 17pablo.js2
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • Unnamed Avatar

    The random tests still print this instead of input:

    For sol(<function feed_the_dogs at 0x7fd7da1f6b60>)
    
  • dfhwze Avatar

    Undocumented behavior:

    BUT if the dog's closest bowls are at the same distance from him, 
    he will have to move and eat from the one that is farthest away from the dog closest to him. 
    ...  HOWEVER, if the two dogs surrounding him are at the same distance away from him, then the dog 
    will be confused and he'll stay in place, losing his turn to eat for that round.
    
    • Why exacly 2 dogs, what if more than 2 dogs are at the same distance?
    • What if the closest food to the left and right of the dog are at the same distance of the closest dog to our dog, what is the tie-breaker in this case? This case occurs if another dog is at the same location as the current dog.
    • Does our dog only get confused if multiple other dogs are at the same distance when some of them are to the left and some to the right of the dog, or also if all of them are on one side? Let's say two dogs are 1 unit to the left of the dog, and there is close food 2 units to the left, and 2 units to the right of our dog, should the dog go right, or get confused?
  • dfhwze Avatar

    I solve all sample tests but practically none of the random tests (Python). This means the sample tests are not a good representation of what to expect in random tests.

  • david.pb Avatar

    Solved some problems in the python solution:

    • Python random tests have cases with one dog

    • In python function name should be snake_case (feed_the_dogs).

    • Python: the random tests print something else instead of the function arguments:

  • mauro-1 Avatar

    Why feed_the_dogs([2, 5, 1, 3], [1, 2, 2, 0]) should be [1, 2, 3, 1] (from random tests)?

    In [257]: feedthedogs.feed_the_dogs([2, 5, 1, 3], [1, 2, 2, 0])
    food=[2, 5, 1, 3] dogs=[1, 2, 2, 0]  dogs[0]=1 food[1]=5  eat food[1]->4
    food=[2, 4, 1, 3] dogs=[1, 2, 2, 0]  dogs[1]=2 food[2]=1  eat food[2]->0
    food=[2, 4, 0, 3] dogs=[1, 2, 2, 0]  dogs[2]=2 food[2]=0  stay                         nearest_food=[1, 3] nearest_dogs=[2]
    food=[2, 4, 0, 3] dogs=[1, 2, 2, 0]  dogs[3]=0 food[0]=2  eat food[0]->1
    food=[1, 4, 0, 3] dogs=[1, 2, 2, 0]  dogs[0]=1 food[1]=4  eat food[1]->3
    food=[1, 3, 0, 3] dogs=[1, 2, 2, 0]  dogs[1]=2 food[2]=0  stay                         nearest_food=[1, 3] nearest_dogs=[2]
    food=[1, 3, 0, 3] dogs=[1, 2, 2, 0]  dogs[2]=2 food[2]=0  stay                         nearest_food=[1, 3] nearest_dogs=[2]
    food=[1, 3, 0, 3] dogs=[1, 2, 2, 0]  dogs[3]=0 food[0]=1  eat food[0]->0
    food=[0, 3, 0, 3] dogs=[1, 2, 2, 0]  dogs[0]=1 food[1]=3  eat food[1]->2
    food=[0, 2, 0, 3] dogs=[1, 2, 2, 0]  dogs[1]=2 food[2]=0  stay                         nearest_food=[1, 3] nearest_dogs=[2]
    food=[0, 2, 0, 3] dogs=[1, 2, 2, 0]  dogs[2]=2 food[2]=0  stay                         nearest_food=[1, 3] nearest_dogs=[2]
    food=[0, 2, 0, 3] dogs=[1, 2, 2, 0]  dogs[3]=0 food[0]=0  move dogs[3]->1 food[1]->1   nearest_food=[1] 
    food=[0, 1, 0, 3] dogs=[1, 2, 2, 1]  dogs[0]=1 food[1]=1  eat food[1]->0
    food=[0, 0, 0, 3] dogs=[1, 2, 2, 1]  dogs[1]=2 food[2]=0  move dogs[1]->3 food[3]->2   nearest_food=[3] 
    food=[0, 0, 0, 2] dogs=[1, 3, 2, 1]  dogs[2]=2 food[2]=0  move dogs[2]->3 food[3]->1   nearest_food=[3] 
    food=[0, 0, 0, 1] dogs=[1, 3, 3, 1]  dogs[3]=1 food[1]=0  move dogs[3]->3 food[3]->0   nearest_food=[3] 
    food=[0, 0, 0, 0] dogs=[1, 3, 3, 3]  dogs[0]=1 food[1]=0  end
    Out[257]: [1, 3, 3, 3]  # should be [1, 2, 3, 1]
    
  • mauro-1 Avatar

    In python function name should be snake_case (feed_the_dogs).

  • Unnamed Avatar

    There will always be at least two dogs.

    Python random tests have cases with one dog.

  • Unnamed Avatar

    Python: the random tests print something else instead of the function arguments:

    For sol(<function feedTheDogs at 0x7f52604aedd0>)
    : [50] should equal [86]
    
  • yLaWy Avatar

    I can't believe someone made a kata about "What the dog doin"

  • Mercy Madmask Avatar

    There are still some solutions passing when they shouldn't

  • Chrono79 Avatar

    Small typo:

    The bolws are always placed on a straight line.

    should be

    The bowls are always placed on a straight line.

  • Mercy Madmask Avatar

    For the sample test: [0,1,2,3,4], [2,2]

    Turn 1: Dog 0 eats in pos 2 -> [0,1,1,3,4], [2,2]
    Turn 2: Dog 1 eats in pos 2 -> [0,1,0,3,4], [2,2]
    Turn 3: Dog 0 sees food in pos 1 and 3, but both are the same distance from the other dog -> Stay
    Turn 4: Dog 1 sees food in pos 1 and 3, but both are the same distance from the other dog -> Stay
    Repeat ad infinitum

    What should the dogs do?

  • Voile Avatar

    Modifying the input will break the random testing, like this

  • Voile Avatar

    There are solutions that doesn't pass the sample tests but pass all the random tests, so the random tests are not good enough.

    (Also, actual tests should contain all the fixed tests in sample tests, and possibly more. Random tests can't catch everything.)

  • Voile Avatar

    Description of the task is lacking a lot of details and the examples aren't helping at all:

    Each dog will take turns to perform actions, starting from left to right

    Left to right in location, or in the input array?

    If the bowl is empty (is 0), the dog will move to the closest bowl and eat a serving

    Do you mean "closest non-empty bowl"?

    If the dog's closest bowls are at the same distance from the dog, the dog will then reasses and move to the one furthest away from another dog

    What is "another dog"? Does the dog itself count? What if the bowl is already occupied by other dogs? What if there are no other dogs (because only 1 dog exists)? Also what happens if they are also the same distances from another dog (which happens often as bowls are usually occupied with dogs)?

    (btw, typo: reasses -> reassess)

    If there are two dogs surrounding him, and both dogs are at the same distance away from him

    Does this mean "there is a dog both on the left and right with the same distance away from him"? "Surrounding" would give an implication that those dogs have to be adjacent.

    then the dog will be confused and he'll stay in place, confused, losing his turn to eat for that round

    So this applies to bowls with food as well? The dog will just skip its turn entirely?

    After all the dogs have finished eating, return a collection with the last positions of the dogs.

    Immediately, or after a round? Your examples only shows the state of the bowls and dogs after every round, but most things are decided at the scale of every dog's turn, so this is confusing.


    Also, I think it's better to specify the configuration of the bowls. It could've been circular and loop from both sides.