Strict IPv4 Validator
150 points · 0 solved
Input validation bugs are where SSRF filters and allow-lists break. The first line is T; each of the next T lines is a candidate address.
Print VALID only if the line is exactly four decimal parts joined by ., where each part is 1–3 ASCII digits, its value is 0–255, and it has no leading zero (except the part 0 itself). Anything else — spaces, signs, hex, extra dots — is INVALID.
Example 1 input
4 192.168.1.1 300.1.1.1 10.01.0.1 localhost
Expected output
VALID INVALID INVALID INVALID
main.py
Ctrl+Enter runs · Ctrl+Shift+Enter submits