Cloud Big Data Technologies uses this calculation to validate paired scoring distributions. Given the face values of two N-sided dice, P and Q, count how many ordered outcomes result in P winning, Q winning, or a tie.
Each outcome rolls one face from P and one face from Q. Duplicate face values represent different physical sides and must be counted separately.
Implement count_dice_outcomes(P, Q), where P and Q are lists of integers with the same length N. Return [p_wins, q_wins, ties], where p_wins counts pairs (p, q) with p > q, q_wins counts pairs with q > p, and ties counts pairs with p == q.
The result must count all N² ordered pairs without explicitly enumerating every pair.
def count_dice_outcomes(P, Q):