You find yourself standing at the edge of a [w] x [h] -room in NetHack. +@--------+ |~~ | | | | | | | | | +---------+ You can see only two pixels ahead but are certain that the room is filled with long worm. Perhaps it is like this: +---------+ |~~~~~~~~~| |~~~~~w~~~| |w~~~~~~w~| |~~~~~~~~~| |~~~~~w~~~| +---------+ . The situation has been chosen uniformly at random from the set of possible situation. A possible situation is an assignment to each pixel either: * a direction, indicating the direction towards the head of the unique worm 'owning' the pixel (if the pixel is not a head) * the token 'head', meaning there's a head at this pixel. AND such that (1,1) and (1,2) are non-heads ('~'). One possible assignment for the example above is: +---------+ |>>>>>>>>v| |^<<<v>v>vwv| |>^>^>^>^v| |^<<<= 8 (head included). You can kill either the '~' at (1,1) or at (1,2). Which should you kill in order to kill as many long worms as possible on average (an average of numbers which belong to {0,1,2}, of course)?