Reported July 2026
OpenAIbit manipulation

IPv4 Reverse 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 data structure behind this OpenAI question, reported in July 2026, is a 32-bit integer. The prompt looks like string fiddling with octets, but it's a countdown in disguise. You get an IPv4 address, and you return every address from it down to 0.0.0.0, inclusive. It came up as the second part of a phone-screen prompt about reversing an iterator. If you've got an OA invite, expect the same twist. Parse once, count down, format each step. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but this one is easy to hold in your head.

The problem

You are given an IPv4 address as a dotted-decimal string. Starting at that address, visit every IPv4 address in decreasing numeric order until 0.0.0.0 is reached.
The starting address and 0.0.0.0 are both included. Decrementing an address borrows across octets, so the address before 10.0.1.0 is 10.0.0.255.
Interview context
The second part of the phone-screen prompt reversed the iterator: begin at the supplied IPv4 address, decrement one address at a time, and continue through 0.0.0.0. This function returns the exact finite sequence that iterator would yield.

Function
iterateIPv4Reverse(startIp: String) → String[]

Examples
Example 1
startIp = "0.0.0.2"
return = ["0.0.0.2", "0.0.0.1", "0.0.0.0"]
The address decreases by one until the lower IPv4 bound is included.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to stop thinking in octets. Convert the dotted string to one integer: (a << 24) | (b << 16) | (c << 8) | d. Then loop from that value down to 0, and convert each number back with shifts and masks (n >> 24) & 255, and so on. Borrowing across octets, like 10.0.1.0 going to 10.0.0.255, happens for free because it's just n minus 1. The common pitfall is manually decrementing octets and fumbling the borrow logic. Another is overflow: in languages with signed 32-bit ints, 255.x.x.x goes negative, so use a 64-bit type or an unsigned one. Also remember 0.0.0.0 is included, so the loop condition is n >= 0. Watch output size too, since a big start address yields billions of strings. The examples are small, so build a plain list. If you freeze during the live OA, StealthCoder is the hedge that surfaces this integer approach quickly.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill IPv4 Reverse 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

IPv4 Reverse Iterator FAQ

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

Convert the address to a single 32-bit integer, then count down from it to 0. Each step, format the number back into four octets with shifts and a 255 mask. The borrow across octets happens automatically, so you never write carry logic by hand.

How hard is this question really?+

Easy. There's no clever algorithm, just bit shifting and a loop. The risk is sloppy edge cases: forgetting to include 0.0.0.0, mishandling signed overflow for addresses starting with 128 or higher, and botching the borrow if you decrement octets manually.

Do I need two pointers for this?+

No. The pattern hint points to two-pointers, but the practical approach is one integer counter moving downward. Don't force a second pointer. Parse, loop from the start value to zero, and format each value into a dotted string.

What edge cases should I test?+

Test 0.0.0.0, which returns just itself. Test 0.0.0.2 from the example. Test a borrow case like 10.0.1.0, which should be followed by 10.0.0.255. Also test a high address like 255.255.255.255 to check your integer type doesn't overflow or go negative.

How do I prepare for this in 48 hours?+

Practice converting between dotted strings and integers using shifts and masks until it's automatic. Write the parse and format helpers from memory in your language. Then write the countdown loop. That covers the whole question. Spend the rest of your time on other iterator-style prompts from the same phone screen.

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