public static int minDistance(int col, int row, Set<Integer> positions) { int minDistance = Integer.MAX_VALUE; for (int pos : positions) { int c = pos / 2; int r = pos % 2; int distance = MathUtil.distance(col, row, c, r); minDistance = Math.min(minDistance, distance); } return minDistance; }