Ejemplo n.º 1
0
  private Pair<Integer, Integer> walk(
      final Set<Coordinate> visited,
      final Coordinate[] shape1Coords,
      final Coordinate[] shape2Coords,
      final int start1,
      final int start2,
      final DirectionFactory factory) {

    final int upPos =
        takeBiggestStep(
            visited,
            shape2Coords[start2],
            shape1Coords,
            factory.createLeftFootDirection(start1, shape1Coords.length));

    // even if the left foot was stationary, try to move the right foot
    final int downPos =
        takeBiggestStep(
            visited,
            shape1Coords[upPos],
            shape2Coords,
            factory.createRightFootDirection(start2, shape2Coords.length));

    // if the right step moved, then see if another l/r step can be taken
    if (downPos != start2) {
      return walk(visited, shape1Coords, shape2Coords, upPos, downPos, factory);
    }
    return Pair.of(upPos, start2);
  }