The Most Specific Rule Wins
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- mid
Problem
Your edge proxy screens inbound traffic against a firewall table, where each rule pairs a CIDR block with either `allow` or `block`. A source IP's verdict comes from the most specific rule whose range contains it: when two equally specific rules both match, the one later in the table wins, and an address no rule covers is allowed through. Walk the request log and return each source IP's verdict in arrival order.
Summary
Every packet asks the same question of the firewall. Answer it the way the table intends.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.