sppl
BAN USERYet another solution,
public static void combination(Queue<String> input,List<String> result ) {
if (input.Count == 0) return;
string seed = input.Dequeue();
List<String> copy = new List<string>(result);
foreach (String o in copy) {
result.Add(seed + o);
}
result.Add(seed);
combination(input, result);
}
Take each character in the input character array and put it in a Queue. Pass this queue to the above method.
Victor,
I hope I've understood your question. Here is my explanation. As long as the duck is within r/4 distance from the center of the pond, it is radially faster than the fox. Therefore it can cover radially more distance than the fox. So radially, the duck will go as far as possible from the fox. At some point duck will be exactly on the opposite side of the fox (Imagine a straight line between the duck and the fox). This is true even if the fox switches the directions at any point. The duck will then switch direction and go straight along the radius. The duck has to cover 3r/4 distance. Even if the fox covers four times 3r/4 which is 3r, it still lags behind the duck. Because the fox has to cover pi * r (as it is in the opposite direction) distance to get the duck.
Great Solution. However diagonals need to be handled as IntwPrep pointed out.
- sppl March 02, 2014