Parse and expand an IPv6 address
Company: Liftoff
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates proficiency in IPv6 address parsing, string validation, and canonicalization, testing understanding of hexadecimal hextets and the zero-compression (::) rule within the Coding & Algorithms domain.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('2001:db8::1',)
Expected Output: '2001:0db8:0000:0000:0000:0000:0000:0001'
Explanation: Compressed example.
Input: ('::',)
Expected Output: '0000:0000:0000:0000:0000:0000:0000:0000'
Explanation: All zeros.
Input: ('1:2:3:4:5:6:7:8',)
Expected Output: '0001:0002:0003:0004:0005:0006:0007:0008'
Explanation: Full address.
Input: ('1::2::3',)
Expected Output: 'Invalid'
Explanation: Multiple compression markers.
Hints
- Model object-style prompts as operation streams when needed.
- Handle empty and boundary cases before the main logic.