Avoid Primes
You are given an integer $N$ and must construct a permutation $P$ of integers $[1, N]$. You define $f(P)$ as the number of integers $i$ ($1 \le i < N$) such that $\min(P_i, P_{i + 1})$ is prime. Note that $1$ is not considered a prime integer. For example, $f([4, 2, 1, 6, 5, 3]) = 3$ because $i = 1, 4, 5$ satisfies the condition. Find a permutation with minimum value of $f(P)$. If multiple permu
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start