You need to sign in or sign up before continuing.×
Ad
  • Custom User Avatar

    The random tests still print this instead of input:

    For sol(<function feed_the_dogs at 0x7fd7da1f6b60>)
    
  • Custom User 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?
  • Custom User 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]