The iterator protocol part was fine, __init__ __iter__ __next__, no surprises there.
Start by clarifying requirements: should the iterator yield all addresses including network and broadcast? Then outline the design: parse CIDR, compute network address and total addresses, and implement __iter__ and __next__ to yield each address. Discuss trade-offs like memory efficiency (lazy generation) and edge cases (IPv4 vs IPv6, invalid CIDR).
Pro tip: Mention that you'd use Python's built-in ipaddress module for parsing and validation, but also be prepared to explain how you'd implement the bitwise operations manually if asked to avoid libraries.
Ask whether to include network and broadcast addresses, whether IPv6 support is needed, and how to handle invalid input. This shows attention to detail and avoids incorrect assumptions.
Outline a class with __init__ that parses the CIDR, stores the current address and end address, and implements __iter__ (returns self) and __next__ (returns current and increments, raising StopIteration when done).
Explain how to convert IP to integer, compute the network address and total number of addresses (2^(32-prefix)), and iterate by incrementing the integer and converting back to IP.
Mention memory efficiency of lazy generation, potential performance for large blocks, and whether to use built-in libraries vs manual bit manipulation. Also consider thread-safety if relevant.
Walk through test cases: small CIDR (e.g., /30), edge cases like /32 and /0, and invalid inputs. Show how to verify correctness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.