This question evaluates algorithmic problem-solving and implementation skills in string processing, checksum validation (Luhn), pattern matching, combinatorics for counting masked completions, and single-error recovery for payment-card numbers.
Design and implement a payment-card validation system supporting:
Basic VISA validation (16-digit numbers starting with 4) using the Luhn checksum.
Multi-network validation for VISA, MASTERCARD (16 digits, prefixes 51- 55) and AMEX (15 digits, prefixes 34 or 37), returning UNKNOWN_NETWORK or INVALID_CHECKSUM when appropriate.
Redacted cards containing 1-5 ‘*’ wildcards: count all valid completions per network and output counts sorted alphabetically by network.
Corrupted cards ending in ‘?’ with exactly one error (one digit changed or two adjacent digits swapped): enumerate all possible original valid card numbers with their network names, sorted numerically.
Follow all formatting and performance constraints described in the prompt.