I started okay, got the basic colon-splitting and hex validation down fast.
First clarify the exact validation rules and edge cases (e.g., whether to accept zone IDs or IPv4-mapped addresses), then outline a step-by-step parsing algorithm that splits on '::', validates each group, and expands to 8 groups. Finally, discuss trade-offs between a regex-based approach and a manual parser, and mention how you would test it.
Pro tip: Mention that you would use a well-tested library in production unless the task is explicitly to implement it, but demonstrate your understanding by walking through the algorithm. Also, highlight that you would write comprehensive unit tests covering edge cases like multiple '::', invalid characters, and IPv4-mapped addresses.
Ask about the expected input format, whether to support IPv4-mapped addresses, zone IDs, and what constitutes a valid IPv6 address. Confirm the output format: fully expanded 8 groups of 4 hex digits, lowercase, separated by colons.
Outline a plan: split the string on '::' to handle shorthand, validate each part, count groups, and expand to 8 groups. For embedded IPv4, detect a dot in the last part, parse it as IPv4, and convert to two hex groups.
Write code to validate each group (1-4 hex digits, no invalid characters), handle leading-zero suppression by padding to 4 digits, and ensure exactly one '::' is allowed. Expand '::' by inserting the correct number of zero groups.
Walk through test cases: valid addresses, invalid ones, edge cases like '::', '::1', '2001:db8::1', and IPv4-mapped. Discuss performance and whether to use regex vs manual parsing, and mention library alternatives.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.