Search
⌘K

IPv4 Address Iterator

Implement an iterator that traverses IPv4 addresses starting from a given address, supporting forward iteration, reverse iteration, and CIDR block iteration.

Asked at:

OpenAI


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid October, 2025

OpenAI

Staff

Given an ipv4 address write an iterator to print the next address. Backwards iterator Iterator that supports CIDR prefixes

Early October, 2025

OpenAI

Mid-level

Write an iterator which given an ip address will iterate through all possible ipv4 addresses. eg: given 255.255.255.250, calling next on iterator should return 255.255.255.250 255.255.255.251 255.255.255.252 255.255.255.253 255.255.255.254 255.255.255.255 Next problem: support reverse order, so given 0.0.0.10 output is 0.0.0.10 0.0.0.9 0.0.0.8 .... 0.0.0.0 Next problem is to take a CIDR address and do the same thing So 255.255.255.10/28

Your account is free and you can post anonymously if you choose.