Find the sum of all positive integers $x$ such that $$|x^2-x-6|$$ has exactly $4$ positive integer divisors.

[i]Proposed by Evan Chang (squareman), USA[/i]
1. Define the function \( f(x) = |x^2 - x - 6| \). We need to find the sum of all positive integers \( x \) such that \( f(x) \) has exactly 4 positive integer divisors.

2. First, evaluate \( f(x) \) for small values of \( x \):
   \[
   f(1) = |1^2 - 1 - 6| = |1 - 1 - 6| = | - 6| = 6
   \]
   \[
   f(2) = |2^2 - 2 - 6| = |4 - 2 - 6| = | - 4| = 4
   \]
   \[
   f(3) = |3^2 - 3 - 6| = |9 - 3 - 6| = |0| = 0
   \]
   Since \( f(1) = 6 \) and \( f(2) = 4 \), and both 6 and 4 do not have exactly 4 divisors, we discard \( x = 1 \) and \( x = 2 \). For \( x = 3 \), \( f(3) = 0 \), which also does not have 4 divisors.

3. Assume \( x \geq 4 \). Then:
   \[
   f(x) = |x^2 - x - 6| = (x - 3)(x + 2)
   \]
   We need \( f(x) \) to have exactly 4 positive divisors. A number has exactly 4 positive divisors if and only if it is of the form \( p^3 \) (where \( p \) is a prime) or \( pq \) (where \( p \) and \( q \) are distinct primes).

4. **Case 1:** \( f(x) = p^3 \)
   \[
   (x - 3)(x + 2) = p^3
   \]
   The pairs \((x-3, x+2)\) must be \((1, p^3)\) or \((p, p^2)\). This implies:
   \[
   x + 2 - (x - 3) = 5 \implies p^3 - 1 = 5 \quad \text{or} \quad p^2 - p = 5
   \]
   Solving these:
   \[
   p^3 = 6 \quad \text{(impossible since 6 is not a cube of a prime)}
   \]
   \[
   p(p - 1) = 5 \implies p = 2, p - 1 = 5/2 \quad \text{(impossible since 5/2 is not an integer)}
   \]
   Thus, no solutions exist in this case.

5. **Case 2:** \( f(x) = pq \)
   \[
   (x - 3)(x + 2) = pq
   \]
   The pairs \((x-3, x+2)\) must be \((1, pq)\) or \((p, q)\). This implies:
   \[
   x + 2 - (x - 3) = 5 \implies pq - 1 = 5 \quad \text{or} \quad q - p = 5
   \]
   Solving these:
   \[
   pq = 6 \implies (p, q) = (2, 3) \quad \text{or} \quad (3, 2)
   \]
   \[
   q - p = 5 \implies (p, q) = (2, 7) \quad \text{or} \quad (7, 2)
   \]
   Hence, \( f(x) = 2 \cdot 3 = 6 \) or \( f(x) = 2 \cdot 7 = 14 \).

6. For \( f(x) = 6 \):
   \[
   (x - 3)(x + 2) = 6 \implies x^2 - x - 6 = 6 \implies x^2 - x - 12 = 0
   \]
   Solving the quadratic equation:
   \[
   x = \frac{1 \pm \sqrt{1 + 48}}{2} = \frac{1 \pm 7}{2} \implies x = 4 \quad \text{or} \quad x = -3 \quad (\text{discard } x = -3)
   \]

7. For \( f(x) = 14 \):
   \[
   (x - 3)(x + 2) = 14 \implies x^2 - x - 6 = 14 \implies x^2 - x - 20 = 0
   \]
   Solving the quadratic equation:
   \[
   x = \frac{1 \pm \sqrt{1 + 80}}{2} = \frac{1 \pm 9}{2} \implies x = 5 \quad \text{or} \quad x = -4 \quad (\text{discard } x = -4)
   \]

8. The valid solutions for \( x \) are \( x = 4 \) and \( x = 5 \).

9. Summing all valid \( x \):
   \[
   S = 4 + 5 = 9
   \]

The final answer is \(\boxed{9}\).