Softmax turns a vector of raw scores into a probability distribution — every entry lands in (0, 1) and the whole thing sums to 1.
softmax(x)ᵢ = exp(xᵢ) / Σⱼ exp(xⱼ)
Written exactly like that, it breaks. exp(1000) overflows to inf, and inf / inf is nan. The fix is a one-liner that every real implementation uses: subtract the maximum value from every entry first. Because the same constant cancels from numerator and denominator, the result is mathematically identical — but nothing ever gets exponentiated above exp(0) = 1.
Task: write softmax(x) for a list of numbers x, returning the probabilities rounded to 4 decimal places. It must survive inputs in the thousands.