Reported July 2026
OpenAIbit manipulation

IPv4 Forward Iterator

Reported by candidates from OpenAI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live OpenAI OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt at this OpenAI question is treating the address as four separate counters and fumbling the carry. OpenAI candidates reported it in July 2026, and the original phone-screen version wanted a Python iterator class. This version just returns the full list from the start address through 255.255.255.255, inclusive. It looks like string work, but it's really integer arithmetic in disguise. If you blank on the conversion, StealthCoder runs invisibly during the live OA and gives you a working solution so one stuck minute doesn't cost you the round.

The problem

You are given an IPv4 address as a dotted-decimal string. Starting at that address, visit every IPv4 address in increasing numeric order until 255.255.255.255 is reached.
The starting address and 255.255.255.255 are both included. Incrementing an address carries across octets, so the address after 10.0.0.255 is 10.0.1.0.
Interview context
The phone-screen version asked candidates to implement a Python IPV4Iterator with __init__, __iter__, and __next__. It began at the supplied address and yielded every address through the IPv4 upper bound. This function returns the exact finite sequence that iterator would yield.

Function
iterateIPv4Forward(startIp: String) → String[]

Examples
Example 1
startIp = "255.255.255.253"
return = ["255.255.255.253", "255.255.255.254", "255.255.255.255"]
The final octet advances twice before the maximum IPv4 address is reached.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: an IPv4 address is just a 32-bit integer. Parse the four octets into one number with shifts (a<<24 | b<<16 | c<<8 | d), then loop from that number up to 4294967295 inclusive. For each value, rebuild the string with (n>>24)&255, (n>>16)&255, (n>>8)&255, n&255. Carry handling comes free, so 10.0.0.255 becomes 10.0.1.0 with no special cases. The pitfall is hand-rolling carries octet by octet and getting an off-by-one at 255.255.255.255, or looping with a condition that skips the final address. Include the endpoint. Also watch the size: a start like 0.0.0.0 means billions of strings, so the real tests almost certainly start near the top. Don't precompute anything fancy. If the live OA freezes you on the bit math, StealthCoder is the hedge that hands you the conversion cleanly.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill IPv4 Forward Iterator 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass OpenAI's OA.

OpenAI reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

IPv4 Forward Iterator FAQ

What's the trick to the IPv4 Forward Iterator problem?+

Convert the dotted string to a single 32-bit integer, then count up to 4294967295 and convert each value back to dotted form. Carrying across octets happens automatically with integer addition, so you never write carry logic by hand.

How hard is this OpenAI OA question really?+

Easy once you see the integer view. The logic is maybe fifteen lines. It's hard only if you try to increment octets manually and tangle the carries. Most failures come from off-by-one on the final address, not from the algorithm.

Should I include 255.255.255.255 in the output?+

Yes. The statement says both the starting address and 255.255.255.255 are included. If the start is already 255.255.255.255, the answer is a single-element list with just that address. Use an inclusive loop bound.

Do I need to write an actual iterator class?+

The phone-screen version used __init__, __iter__ and __next__ in Python. This function version just returns the full finite list. Same logic either way: hold an integer, yield its dotted form, stop after the maximum value.

How do I prep for this in 48 hours?+

Practice the shift and mask conversion both directions until it's automatic. Then test edge cases by hand: 10.0.0.255 rolling over, 255.255.255.255 alone, and 255.255.255.253 from the example. That covers nearly every failure mode.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with OpenAI.

OA at OpenAI?
Invisible during screen share
Get it