Iterate Canonical IPv6 Addresses
Reported by candidates from OpenAI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The OpenAI OA reported in September 2026 looks like a warm-up, and that's the trap. You get an IPv6 string, a list of +1 and -1 moves, and you return the address after each one. The pattern is string parsing plus big-integer arithmetic, and the whole question is whether you handle carry and borrow across hex groups without breaking on zero padding. If you've got an invite in your inbox, this is the one where the easy path fails quietly on a boundary. StealthCoder is the safety net if you blank on the live OA, but the idea is small enough to hold in your head.
The problem
start is an IPv6 address in canonical lowercase form: exactly eight groups of four hexadecimal digits separated by colons. Apply every value in moves cumulatively. A move of 1 increments the unsigned 128-bit address, and -1 decrements it. Return the canonical address after each move. The input guarantees that no step underflows below zero or overflows above 2^128 - 1. Function moveIPv6Addresses(start: String, moves: int[]) → String[] Examples Example 1 start = "0000:0000:0000:0000:0000:0000:0000:00ff" moves = [1,1,-1] return = ["0000:0000:0000:0000:0000:0000:0000:0100","0000:0000:0000:0000:0000:0000:0000:0101","0000:0000:0000:0000:0000:0000:0000:0100"] Carry crosses the low byte boundary and moves are cumulative. Example 2 start = "0000:0000:0000:0000:ffff:ffff:ffff:ffff" moves = [1,-1] return = ["0000:0000:0000:0001:0000:0000:0000:0000","0000:0000:0000:0000:ffff:ffff:ffff:ffff"] Carry and borrow cross the 64-bit midpoint. Example 3 start = "abcd:0000:0000:0000:0000:0000:0000:0000" moves = [] return = [] No moves produce no addresses. Constraints 0 <= moves.length <= 200000. Every move is exactly -1 or 1. start has eight four-digit lowercase hexadecimal groups. Every intermediate address stays in the unsigned 128-bit range.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to stop treating the address as eight groups. Strip the colons, parse the 32 hex digits into one 128-bit integer, then keep a running value and add each move. Format after every step. Python gives you big ints for free. In Java, use BigInteger. In C++ use unsigned __int128 or two 64-bit halves with manual carry. The pitfall is formatting. You must zero-pad to 32 hex digits, lowercase, then re-insert a colon every four characters. Dropping leading zeros is the classic bug. Example 2 crosses the 64-bit midpoint, so a split-halves solution that forgets carry or borrow fails there. With up to 200000 moves, build the output list once and avoid re-parsing the string each step. Each move is O(1) work plus formatting. If you freeze on the 128-bit handling during the live OA, StealthCoder can supply the working solution while you stay calm.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Iterate Canonical IPv6 Addresses cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass OpenAI's OA.
OpenAI reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Iterate Canonical IPv6 Addresses FAQ
What's the trick in the OpenAI IPv6 iterator problem?+
Convert the whole address to a single 128-bit integer, apply moves to a running total, and format back after each step. Don't touch groups individually. That removes every carry and borrow edge case, including the one across the 64-bit midpoint in Example 2.
How do I format the address back correctly?+
Convert the integer to hex, lowercase, and left-pad with zeros to exactly 32 characters. Then split into eight chunks of four and join with colons. Missing padding is the most common failure, especially for addresses with many leading zero groups.
Which languages handle 128-bit values easily here?+
Python ints are unbounded, so it's trivial. Java has BigInteger. C++ can use unsigned __int128, though printing it needs manual hex conversion. Otherwise store two 64-bit halves and propagate carry or borrow yourself when the low half wraps.
Is performance a concern with 200000 moves?+
Not if you parse once. Each move is a single add or subtract on the running value, then one format call. That's linear in the number of moves. Re-parsing the string from scratch on every step is the only way to make this needlessly slow.
How do I prepare for this in 48 hours?+
Write the solution once from scratch and test the three examples, especially the 00ff to 0100 carry and the midpoint crossing. Also test an empty moves list. Practice the pad-and-split formatting until you can type it without looking anything up.