Company: AutoRABIT
Difficulty: easy
Validate IPv4 Addresses As a Network Engineer, your first task is to validate IPv4 addresses given to you. You have been given a list of IP addresses and you need to check whether they are valid or not. Valid IPv4 addresses are of the format XXX.XXX.XXX.XXX , where XXX represents a byte which can be any positive integer less than or equal to 255. Note: 121.23.0.1 is a valid IPv4 address, where the second, third, and fourth bytes are truncated to two, one, and one digit, respectively. A candidate string is therefore valid when all of the following hold (inferred — the source states the format and gives one example but never spells the rules out one by one; these are the rules under which the source's own note holds and 121.23.0.1 is valid) : Splitting the string on the . character produces exactly four parts. Every part is non-empty and consists only of the digits 0 - 9 — no sign, no letters, no spaces. The numeric value of every part is at most 255 . Leading zeros are allowed, so 01.2.