Code Room
CodingMediumcod-g994
Subject SecurityLevel Mid–Senior~18 minCommon in Security interviewsIndustries Software development

Question

Implement the Luhn checksum used to validate credit-card numbers. Given a card `number` as a string (which may contain spaces or dashes as separators), return True if it passes the Luhn check. The algorithm: from the rightmost digit moving left, double every second digit; if a doubled value exceeds 9 subtract 9; sum all resulting digits; the number is valid if the total is divisible by 10. Ignore non-digit separators. An input with no digits is invalid.

Implement
luhn_valid(number: str) → bool
Examples
in["4539148803436467"]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.