Domanda di colloquio di AMD

Write an algorithm to make sure this IP Address is valid

Risposta di colloquio

Anonimo

1 giu 2025

We can write script for this I also faced similar in other interviews import re ip_pattern = r'\b(?:(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})\.){3}(?:25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})\b' test_ips = ["192.168.1.1", "999.1.1.1", "255.255.255.255", "256.100.100.100", "1.1.1"] for ip in test_ips: print(ip, "=>", bool(re.fullmatch(ip_pattern, ip)))