Question
Implement an IPv4 firewall allowlist. Given a list of CIDR blocks (strings like '10.0.0.0/8' or a bare '192.168.1.5' meaning /32) and a candidate IPv4 address string, return True if the address falls inside ANY of the CIDR blocks. Parse dotted-quad addresses to 32-bit integers yourself; for a block a.b.c.d/n, the address matches if its top n bits equal the block's top n bits. A /0 block matches everything. You may use the ipaddress module is NOT required — implement the masking directly.
ip_allowed(cidrs: list[str], ip: str) → bool[["10.0.0.0/8","192.168.1.0/24"],"10.5.4.3"]outtrueState your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.